当前位置:网站首页>postgresql 日期处理函数用法
postgresql 日期处理函数用法
2022-07-24 05:31:00 【hsg77】
postgresql 日期处理函数用法
select now(); --当前时间 2021-04-21 11:36:56
SELECT EXTRACT (year FROM now()); --年 2021
SELECT EXTRACT (quarter FROM now()); --季 02
SELECT EXTRACT (month FROM now()); --月 04
SELECT EXTRACT (day FROM now()); --月中天 21
SELECT EXTRACT (week FROM now()); --周 16
SELECT EXTRACT (isodow FROM now()); --周中天 3
SELECT EXTRACT (hour FROM now()); --時 11
SELECT EXTRACT (minute FROM now()); --分 36
SELECT EXTRACT (second FROM now()); --秒 56.909161
获取年份:extract(year from 日期)
获取月份:extract(month from 日期)
获取季度:extract(quarter from 日期)
select
months 月份,max(最高气温)最高温, min(最低气温)最低温, max(温差) 温差
from (
select (extract(year from 日期)||'-'||extract(month from 日期)) as months, 最高气温, 最低气温, 最高气温-最低气温 温差
from weather
where extract(year from 日期) = '2018'
) a group by a.months order by months
postgresql 测试数据 别名要加as
mysql 要跟from dual
postgresql 则不跟dual
select 2 as id,'技术' as name, 2000 as value, '' as parent
union
select 1 as id,'销售' as name, 5000 as value, '' as parent
union
select 3 as id,'电话销售' as name, 2000 as value, '1' as parent
union
select 4 as id,'门店销售' as name, 3000 as value, '1' as parent
union
select 5 as id,'促销' as name, 2000 as value, '4' as parent
select
'武侯区' as name, 123 as value
union
select
'青羊区' as name, 223 as value
union
select
'金牛区' as name, 453 as value
union
select
'双流区' as name, 423 as value
union
select
'新都区' as name, 163 as value
union
select
'郫都区' as name, 193 as value
union
select
'温江区' as name, 343 as value
union
select
'青白江区' as name, 443 as value
union
select
'锦江区' as name, 403 as value
union
select
'成华区' as name, 553 as value
union
select
'双流区' as name, 553 as value
union
select
'成都市' as name, 489 as value
union
select
'四川省' as name, 500 as value
union
select
'广东省' as name, 200 as value
union
select
'新疆维吾尔自治区' as name, 1000 as value
union
select
'青海省' as name, 900 as value
union
select
'西藏自治区' as name, 900 as value
—the—end—
边栏推荐
- Account and authority management
- 这些坑你不掌握,你还真不敢用BigDecimal
- 【微信小程序】一文搞懂条件渲染、列表渲染以及wxss模板样式
- Today, let's talk about the underlying architecture design of MySQL database. How much do you know?
- 记录PHPSerializer工具类反序列化遇到的坑
- DHCP principle and configuration
- 深入了解MySQL 两把锁啥时候用(表锁,行锁)
- Responsive page
- JS - numerical processing (rounding, rounding, random numbers, etc.)
- Rsync (I): basic commands and usage
猜你喜欢

【LVGL(4)】对象的事件及事件冒泡

You don't know these pits. You really don't dare to use BigDecimal

Take you to understand the inventory deduction principle of MySQL database

Jenkins CI CD
![[small object velocimeter] only principle, no code](/img/df/b8a94d93d4088ebe8d306945fd9511.png)
[small object velocimeter] only principle, no code

Learn more about when to use MySQL two locks (table lock and row lock)

Responsive page

PXE technology network installation

文件系统与日志分析

oss授权单个bucket权限
随机推荐
Learn more about when to use MySQL two locks (table lock and row lock)
NFS shared services and experiments
CentOS operating system security reinforcement
JS - calculate the side length and angle of a right triangle
【LVGL(2)】LVGL入门,在CodeBlock上进行模拟以及移植STM32
类加载的过程(生命周期)详情分析
【LVGL(5)】标签的(label)用法
Kubernetes' deployment, service concept, dynamic capacity expansion
Special effects - click the mouse and the randomly set text will appear
JSONObject按照key的A——Z顺序排序
kubernetes简介(kubernetes优点)
The history command adds time to the history
Install agent and proxy using custom ZABBIX package (version 4.0.5)
kubernetes 的Deployment(部署),Service概念,动态扩缩容
Combination of grep and regular
FTP服务与实验
STM32 MP3 music player based on FatFs r0.14b & SD card (also a simple application of FatFs)
Depth first search (template use)
【LVGL(3)】设置对象大小、位置、盒子模型、状态
Machine learning case: smoking in pregnant women and fetal health