1 2014-12-28 00:00:00.000 2 2015-01-04 00:00:00.000 3 2015-01-11 00:00:00.000 4 2015-01-18 00:00:00.000 5 2015-01-25 00:00:00.000 6 2015-02-01 00:00:00.000 7 2015-02-08 00:00:00.000 8 2015-02-15 00:00:00.000 9 2015-02-22 00:00:00.000 10 2015-03-01 00:00:00.000 11 2015-03-08 00:00:00.000 12 2015-03-15 00:00:00.000 13 2015-03-22 00:00:00.000 14 2015-03-29 00:00:00.000 15 2015-04-05 00:00:00.000 16 2015-04-12 00:00:00.000 17 2015-04-19 00:00:00.000 18 2015-04-26 00:00:00.000 19 2015-05-03 00:00:00.000 20 2015-05-10 00:00:00.000 21 2015-05-17 00:00:00.000 22 2015-05-24 00:00:00.000 23 2015-05-31 00:00:00.000 24 2015-06-07 00:00:00.000 25 2015-06-14 00:00:00.000 26 2015-06-21 00:00:00.000 27 2015-06-28 00:00:00.000 28 2015-07-05 00:00:00.000 29 2015-07-12 00:00:00.000 30 2015-07-19 00:00:00.000 31 2015-07-26 00:00:00.000 32 2015-08-02 00:00:00.000 33 2015-08-09 00:00:00.000 34 2015-08-16 00:00:00.000 35 2015-08-23 00:00:00.000 36 2015-08-30 00:00:00.000 37 2015-09-06 00:00:00.000 38 2015-09-13 00:00:00.000 39 2015-09-20 00:00:00.000 40 2015-09-27 00:00:00.000 41 2015-10-04 00:00:00.000 42 2015-10-11 00:00:00.000 43 2015-10-18 00:00:00.000 44 2015-10-25 00:00:00.000 45 2015-11-01 00:00:00.000 46 2015-11-08 00:00:00.000 47 2015-11-15 00:00:00.000 48 2015-11-22 00:00:00.000 49 2015-11-29 00:00:00.000 50 2015-12-06 00:00:00.000 51 2015-12-13 00:00:00.000 52 2015-12-20 00:00:00.000 53 2015-12-27 00:00:00.000 WITH tmp as (SELECT idx = 0 UNION ALL SELECT idx = idx + 1 FROM tmp WHERE idx < 364 ) SELECT dw = CAST(dw as varchar) , startWeek = DATEADD(dd, -1 * DATEPART(DW, MIN(dt)) + 1, MIN(dt) ) FROM (SELECT idx , dt = DATEADD(DD, idx, '2015-01-01') , dw = datepart(WW, DATEADD(DD, idx, '2015-01-01')) FROM tmp ) q GROUP BY dw option (maxrecursion 0) mssql에서 뽑은 쿼리인데요.. postgresql 로 변환중인데 53주를 뽑아낼수 있나요.. 너무다른거같네요.. 기준날짜는 2015-01-01 입니다.. 답변 부탁드립니다.. |