with recursive t (dw , week) as
( select 1, ''||''
union all
--(select dw+1 from (select week||2 from t) t)
select dw+1 , generate_series(date_trunc('week', '2015-01-01'::timestamp )-interval '1 days'
,date_trunc('week', '2016-01-01'::timestamp )
,'1 week')||'.000' AS week from t
) select dw, week from t limit 53
이게 쿼리 인데요. 현재 저상태로 출력을하면 아래 형식대로 출력이 됩니다.
아래 dw가 integer인데 계속 동일하게 1씩만 증가해서 2만계속 찍네요..
저것 1씩증가해서 53까지 찍을수있는 방법있나요
dw week
1 ""
2 "2014-12-28 00:00:00.000"
2 "2015-01-04 00:00:00.000"
2 "2015-01-11 00:00:00.000"
2 "2015-01-18 00:00:00.000"
2 "2015-01-25 00:00:00.000"
2 "2015-02-01 00:00:00.000"
2 "2015-02-08 00:00:00.000"
2 "2015-02-15 00:00:00.000"
2 "2015-02-22 00:00:00.000"
2 "2015-03-01 00:00:00.000"
2 "2015-03-08 00:00:00.000"
2 "2015-03-15 00:00:00.000"
2 "2015-03-22 00:00:00.000"
2 "2015-03-29 00:00:00.000"
2 "2015-04-05 00:00:00.000"
2 "2015-04-12 00:00:00.000"
2 "2015-04-19 00:00:00.000"
2 "2015-04-26 00:00:00.000"
2 "2015-05-03 00:00:00.000"
2 "2015-05-10 00:00:00.000"
2 "2015-05-17 00:00:00.000"
2 "2015-05-24 00:00:00.000"
2 "2015-05-31 00:00:00.000"
2 "2015-06-07 00:00:00.000"
2 "2015-06-14 00:00:00.000"
2 "2015-06-21 00:00:00.000"
2 "2015-06-28 00:00:00.000"
2 "2015-07-05 00:00:00.000"
2 "2015-07-12 00:00:00.000"
2 "2015-07-19 00:00:00.000"
2 "2015-07-26 00:00:00.000"
2 "2015-08-02 00:00:00.000"
2 "2015-08-09 00:00:00.000"
2 "2015-08-16 00:00:00.000"
2 "2015-08-23 00:00:00.000"
2 "2015-08-30 00:00:00.000"
2 "2015-09-06 00:00:00.000"
2 "2015-09-13 00:00:00.000"
2 "2015-09-20 00:00:00.000"
2 "2015-09-27 00:00:00.000"
2 "2015-10-04 00:00:00.000"
2 "2015-10-11 00:00:00.000"
2 "2015-10-18 00:00:00.000"
2 "2015-10-25 00:00:00.000"
2 "2015-11-01 00:00:00.000"
2 "2015-11-08 00:00:00.000"
2 "2015-11-15 00:00:00.000"
2 "2015-11-22 00:00:00.000"
2 "2015-11-29 00:00:00.000"
2 "2015-12-06 00:00:00.000"
2 "2015-12-13 00:00:00.000"
2 "2015-12-20 00:00:00.000"
2 "2015-12-27 00:00:00.000"
|