728x90
master.dbo.spt_values 테이블 활용한 쿼리입니다.
DECLARE @FIRST VARCHAR(10), @LAST VARCHAR(10) select @FIRST=dateadd(day,-(day('2000-02-04')-1),'2000-02-04') select @LAST=dateadd(month,1,'2000-02-04')-(day('2000-02-04')) SELECT MIN(CASE WHEN DATEPART(DW,DT.AttendDateSet) = 1 THEN AttendDateSet END) SUN, MIN(CASE WHEN DATEPART(DW,DT.AttendDateSet) = 2 THEN AttendDateSet END) MON, MIN(CASE WHEN DATEPART(DW,DT.AttendDateSet) = 3 THEN AttendDateSet END) TUE, MIN(CASE WHEN DATEPART(DW,DT.AttendDateSet) = 4 THEN AttendDateSet END) WED, MIN(CASE WHEN DATEPART(DW,DT.AttendDateSet) = 5 THEN AttendDateSet END) THU, MIN(CASE WHEN DATEPART(DW,DT.AttendDateSet) = 6 THEN AttendDateSet END) FRI, MIN(CASE WHEN DATEPART(DW,DT.AttendDateSet) = 7 THEN AttendDateSet END) SAT FROM ( select convert(char(10),dateadd(d,number,@FIRST),120) AS AttendDateSet from master.dbo.spt_values where type = 'P' and number <= datediff(d,@FIRST,@LAST) ) DT GROUP BY DATEPART(WW,DT.AttendDateSet)
'it > programming' 카테고리의 다른 글
OWASP Top 10 List 에 대한 정리 (0) | 2015.10.30 |
---|---|
[ASP] 페이징 개발 (0) | 2015.07.01 |
[ASP classic] include 활용하기 (0) | 2015.06.30 |