PostgreSQL分组(GROUP BY子句)

PostgreSQL分组(GROUP BY子句)

select u.created_ts, count(*) from tb_user u group by u.created_ts
注意:不能缺少聚合函数
在这里插入图片描述
按月分组统计
select
to_char(to_timestamp(created_ts/1000), ‘YYYY-MM’) as month,
count(id) as total_call
from tb_user
where
created_ts between 1548568440000 and 1552456440000
group by month
order by month
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/qq_31519989/article/details/88532969