我有一张桌子,表上有一列ctimetype time without time zone。
ctime
time without time zone
| cdate | ctime +------------+---------- | 2016-12-24 | 12:02:17 | 2016-12-24 | 12:02:32 | 2016-12-24 | 12:03:00 | 2016-12-24 | 12:02:10
我想按两者分组cdate,ctime但ctime只想数小时。
cdate
用途date_trunc:
date_trunc
group by cdate, date_trunc('hour', ctime)