SELECT
COUNT(SUP_NO) AS CASH_COUNT,
SUM(Rcpt_Amt) AS CASH_SUM
FROM GT..TBLCREDIT
WHERE (CASE WHEN @QUARETER = '01' THEN LEFT(RCPT_DT, 6) BETWEEN '201401' AND '201403'
WHEN @QUARETER = '02' THEN LEFT(RCPT_DT, 6) BETWEEN '201404' AND '201406'
WHEN @QUARETER = '03' THEN LEFT(RCPT_DT, 6) BETWEEN '201407' AND '201409'
WHEN @QUARETER = '04' THEN LEFT(RCPT_DT, 6) BETWEEN '201410' AND '201412'
ELSE '' END)
이렇게 @ QUARETER 값에 따라서 1분기~ 4분기를 CASE 문으로 표현할수 있나요??
Comment 1
-
Hisory
2014.07.29 18:05
select datepart(quarter,getdate()) 를 활용하심이....