PostgreSQL 實現按月按年,按日統計 分組統計


endtime 是 timestamp

select to_char(endtime, 'YYYY-MM-DD') as d ,  count(objectid) 
FROM sde.polygon where endtime>='2004-09-01 00:00:00' and endtime <='2004-10-01 23:59:59' group by d

endtime 是 字符串時

select to_char(to_timestamp(endtime::bigint), 'YYYY-MM-DD') as d ,  count(objectid) 
FROM sde.polygon where endtime>='2004-09-01 00:00:00' and endtime <='2004-10-01 23:59:59' group by d

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM