Sql Query to print Calender Month in Teradata
SELECT
MAX(CASE WHEN day_of_week=1 THEN day_of_month ELSE NULL END ) SUN
,MAX(CASE WHEN day_of_week=2 THEN day_of_month ELSE NULL END ) MON
,MAX(CASE WHEN day_of_week=3 THEN day_of_month ELSE NULL END ) TUE
,MAX(CASE WHEN day_of_week=4 THEN day_of_month ELSE NULL END ) WED
,MAX(CASE WHEN day_of_week=5 THEN day_of_month ELSE NULL END ) THU
,MAX(CASE WHEN day_of_week=6 THEN day_of_month ELSE NULL END ) FRI
,MAX(CASE WHEN day_of_week=7 THEN day_of_month ELSE NULL END ) SAT
FROM sys_calendar.calendar
WHERE year_of_calendar='2013'
AND month_of_year='03'
GROUP BY week_of_month
ORDER BY week_of_month;
No comments:
Post a Comment