select * from ( select 

to_char(reg_date, 'yyyymmdd hh') as m_date,

count(*) as cnt,

from measure_logs 

WHERE reg_date >= CAST('2016-02-03 00:00:00' as timestamp) 

AND reg_date <= CAST('2016-03-02 23:59:59' as timestamp) 

group by rollup(to_char(reg_date, 'yyyymmdd hh'))

) as t; 

위는 postgreSQL에서 사용되었던 날짜별 통계 여기서 각 필드의 평균 / 최소 / 최대값을 구하는 부분을 카운터 함수 부분에 추가하면 더욱 유용하게 사용 되는 부분이다. 


+ Recent posts