년,월,일,시,분 단위로 그룹핑하여 보기 각종 통계시 활용
select DATEPART(YEAR, adddt) '년'
,DATEPART(MONTH, adddt) '월'
,DATEPART(DAY, adddt) '일'
,DATEPART(HOUR, adddt) '시'
-- ,(DATEPART(MINUTE, adddt) / 10)
,count(*) FRom 테이블명 with(nolock)
GROUP BY
DATEPART(YEAR, adddt)
,DATEPART(MONTH, adddt)
,DATEPART(DAY, adddt)
,DATEPART(HOUR, adddt)
--,(DATEPART(MINUTE, adddt) / 10)
order by 1,2,3,4
select TIMEFROMPARTS(
DATEPART(HOUR, adddt),
DATEPART(MINUTE, adddt) / 5 * 5, 0,
0,
0)
,count(*) FRom 테이블명 with(nolock)
group by TIMEFROMPARTS(
DATEPART(HOUR, adddt),
DATEPART(MINUTE, adddt) / 5 * 5, 0,
0,
0)
order by 1