Thursday, December 23, 2010

Printing a calender in Oracle

this is a good solution in my perspective to print a calender using basic SQL the query lucks rusty but easy to grab your attention => select max(decode(to_char(dt,'d'),1, to_char(dt,'dd'),null)) sun, max(decode(to_char(dt,'d'),2,to_char(dt,'dd'),null)) mon, max(decode(to_char(dt,'d'),3,t0_char(dt,'dd'),null)) tue, max(decode(to_char(dt,'d'),4,to_char(dt,'dd'),null)) wed, max(decode(to_char(dt,'d'),5,to_char(dt,'dd'),null)) thu, max(decode(to_char(dt,'d'),6,to_char(dt,'dd'),null)) fri, max(decode(to_char(dt,'d'),7,to_char(dt,'dd'),null)) sat from (select trunc(to_date(sysdate) ,'year')+rownum-1 dt, trunc((rownum+to_char(trunc (to_date(sysdate,'year'),'d')-1)/7+.9999 week from dual where rownum <= to_number((to_char(add_months(trunc(to_date(sysdate),'year'),12),'ddd'-1))) calender where to_char(dt,'mm') = to_char( to_date(sysdate),'mm') group by week order by week give the month name for the specific calender of the month will try to make it simple and simple in upcoming days

No comments:

Post a Comment