pg按日,周,月进行数据统计

pg数据库按周,月统计数据

SELECT date_trunc('WEEK', insert_time) as insertDate, SUM(data_increment) as dataTotal,SUM(human_increment) as humanTotal  from human_data_sum t where t.idtype=? GROUP BY insertDate ORDER BY insertDate DESC

SELECT date_trunc('MONTH', insert_time) as insertDate, SUM(data_increment) as dataTotal,SUM(human_increment) as humanTotal  from human_data_sum t where t.idtype=? GROUP BY insertDate ORDER BY  insertDate DESC

 

posted @ 2018-01-30 14:03  疯狂的蜗牛仔  阅读(3075)  评论(0编辑  收藏  举报