Oracle中利用SQL語句顯示本月日曆

select max(decode(dow, 1, d, null)) Sun,  
       max(decode(dow, 2, d, null)) Mon,  
       max(decode(dow, 3, d, null)) Tue,  
       max(decode(dow, 4, d, null)) Wed,  
       max(decode(dow, 5, d, null)) Thu,  
       max(decode(dow, 6, d, null)) Fri,  
       max(decode(dow, 7, d, null)) Sat  
  from (select rownum d,  
               rownum - 2 +  
               to_number(to_char(trunc(sysdate, 'MM'), 'D')) p,  
               to_char(trunc(sysdate, 'MM') -1 + rownum, 'D') dow  
          from all_objects  
         where rownum <=  
               to_number(to_char(last_day(to_date(sysdate)), 'DD')))  
 group by trunc(p / 7)
相關文章
相關標籤/搜索