■ 주차(Week Number)별 데이터를 집계하는 방법을 보여준다.
▶ 예제 코드 (SQL)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
SELECT A.WeekNumber AS WeekNumber ,A.Name AS Name ,COUNT(*) AS [Count] FROM ( SELECT A.Name AS Name -- 명칭 ,DATEPART(ww, DateTimeWritten) AS WeekNumber -- 주차 FROM PhotoBook AS A WHERE A.MenuID = 44 AND A.CategoryName = '자연' ) A WHERE A.WeekNumber BETWEEN 1 AND 10 -- 1 ~ 10 주차 데이터 GROUP BY A.WeekNumber ,A.Name; |