当前位置:网站首页>PostgreSQL date handler usage
PostgreSQL date handler usage
2022-07-24 06:47:00 【hsg77】
postgresql Date handler usage
select now(); -- current time 2021-04-21 11:36:56
SELECT EXTRACT (year FROM now()); -- year 2021
SELECT EXTRACT (quarter FROM now()); -- season 02
SELECT EXTRACT (month FROM now()); -- month 04
SELECT EXTRACT (day FROM now()); -- In the middle of the moon 21
SELECT EXTRACT (week FROM now()); -- Zhou 16
SELECT EXTRACT (isodow FROM now()); -- Zhou Zhongtian 3
SELECT EXTRACT (hour FROM now()); -- When 11
SELECT EXTRACT (minute FROM now()); -- branch 36
SELECT EXTRACT (second FROM now()); -- second 56.909161
Get year :extract(year from date )
Get month :extract(month from date )
Get Quarterly :extract(quarter from date )
select
months month ,max( The highest temperature ) Maximum temperature , min( Minimum temperature ) Minimum temperature , max( Temperature difference ) Temperature difference
from (
select (extract(year from date )||'-'||extract(month from date )) as months, The highest temperature , Minimum temperature , The highest temperature - Minimum temperature Temperature difference
from weather
where extract(year from date ) = '2018'
) a group by a.months order by months
postgresql Test data Alias should be added as
mysql Want to follow from dual
postgresql Then don't follow dual
select 2 as id,' technology ' as name, 2000 as value, '' as parent
union
select 1 as id,' sales ' as name, 5000 as value, '' as parent
union
select 3 as id,' Telemarketing ' as name, 2000 as value, '1' as parent
union
select 4 as id,' Store sales ' as name, 3000 as value, '1' as parent
union
select 5 as id,' Sales promotion ' as name, 2000 as value, '4' as parent
select
' Wuhou District ' as name, 123 as value
union
select
' Qingyang District ' as name, 223 as value
union
select
' Jinniu District ' as name, 453 as value
union
select
' Shuangliu district ' as name, 423 as value
union
select
' Xindu District ' as name, 163 as value
union
select
' Pidu district ' as name, 193 as value
union
select
' Wenjiang District ' as name, 343 as value
union
select
' Qingbaijiang District ' as name, 443 as value
union
select
' Jinjiang District ' as name, 403 as value
union
select
' Chenghua District ' as name, 553 as value
union
select
' Shuangliu district ' as name, 553 as value
union
select
' Chengdu ' as name, 489 as value
union
select
' Sichuan Province ' as name, 500 as value
union
select
' Guangdong province, ' as name, 200 as value
union
select
' Xinjiang Uygur Autonomous Region ' as name, 1000 as value
union
select
' Qinghai Province ' as name, 900 as value
union
select
' Tibet Autonomous Region ' as name, 900 as value
—the—end—
边栏推荐
猜你喜欢

PyQt5入门——学生管理系统

【波形/信号发生器】基于 STC1524K32S4 for C on Keil

Kubernetes' deployment, service concept, dynamic capacity expansion

创建WPF项目

RAID的配置实验

Combination of grep and regular

API process and code structure

在IDEA里斗个地主不过分吧!

【LVGL(1)】LVGL的简单介绍

Special effects - click the mouse and the randomly set text will appear
随机推荐
Visibility:hidden and display:none
Redis入门
MySQL batch modifies the data table code and character set to utf8mb4
Summary browser object
Responsive page
Redis数据类型-String(字符串类型)
在IDEA里斗个地主不过分吧!
Browser local storage
【LVGL布局】柔性布局
深度优先搜索(模板使用)
kubernetes简介(kubernetes优点)
STM32 MP3 music player based on FatFs r0.14b & SD card (also a simple application of FatFs)
[small object velocimeter] only principle, no code
【小型物体测速仪】只有原理,无代码
NFS shared services and experiments
Solution of forgetting root password in mysql5.7 under Windows
Special effects - when the mouse moves, there will be a custom expression trail
【LVGL】组件的样式的设置、更改、删除API函数
LM393 电压比较器及其典型电路介绍
【LVGL(1)】LVGL的简单介绍