#title 매일 월초부터 현재일까지 월 데이터를 처리한다면 월단위 처리시 현재 월에 대한 데이터를 매일 처리한다면, 현재 월이 언제부터 언제까지라는 데이터를 보여 줄 필요는 있다. {{{ declare @yyyy char(4) , @mm char(2) set @yyyy = '2011' set @mm = '04' --현재가 4월 12일 이라면.. ;with t as ( select convert(date, '2011-04-12') date_key union all select convert(date, '2011-03-01') date_key union all select convert(date, '2011-02-01') date_key ) select left(date_key,7) + case when convert(char(7), getdate()-1, 121) = @yyyy + '-' + @mm and left(date_key,7) = @yyyy + '-' + @mm then '(' + @yyyy + '-' + @mm + '-01 ~ ' + convert(char(10), getdate()-1, 121) + ')' else '' end from t order by 1 /* 2011-02 2011-03 2011-04(2011-04-01 ~ 2011-04-12) */ }}}