PostgreSQL分组(GROUP BY子句)

PostgreSQL分组(GROUP BY子句)

select u.created_ts, count(*) from tb_user u group by u.created_ts
注意:不能缺少聚合函数
PostgreSQL分组(GROUP BY子句)_第1张图片
按月分组统计
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
PostgreSQL分组(GROUP BY子句)_第2张图片

你可能感兴趣的:(工作遇到问题)