2007年9月12日

          This query will return a string in a vertical format.

          SELECT SUBSTR('&&String', ROWNUM, 1)
          FROM all_objects
          WHERE ROWNUM <= LENGTH(TRIM('&STRING'));
          

          Prints a Calendar for the Current Year

          This tip comes from Robert Ware, a DBA at TekSystems, in St. Louis, Missouri.
          This tip prints a calendar for the current year. It can be modified to return other years as well.
          select lpad( Month, 20-(20-length(month))/2 ) month,
          "Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"
          from (select to_char(dt,'fmMonthfm YYYY') month,
          CASE when to_char(dt,'fmMonthfm YYYY') like 'Dec%' AND to_char(dt+1,'iw') = '01' then '53'
          when to_char(dt,'fmMonthfm YYYY') like 'Jan%' AND to_char(dt+1,'iw') = '53' then '.5'
          else to_char(dt+1,'iw')
          END week,
          max(decode(to_char(dt,'d'),'1',lpad(to_char(dt,'fmdd'),2))) "Su",
          max(decode(to_char(dt,'d'),'2',lpad(to_char(dt,'fmdd'),2))) "Mo",
          max(decode(to_char(dt,'d'),'3',lpad(to_char(dt,'fmdd'),2))) "Tu",
          max(decode(to_char(dt,'d'),'4',lpad(to_char(dt,'fmdd'),2))) "We",
          max(decode(to_char(dt,'d'),'5',lpad(to_char(dt,'fmdd'),2))) "Th",
          max(decode(to_char(dt,'d'),'6',lpad(to_char(dt,'fmdd'),2))) "Fr",
          max(decode(to_char(dt,'d'),'7',lpad(to_char(dt,'fmdd'),2))) "Sa"
          from (select trunc(sysdate,'y')-1+rownum dt
          from all_objects
          where rownum <= add_months(trunc(sysdate,'y'),12) - trunc(sysdate,'y'))
          group by to_char(dt,'fmMonthfm YYYY'), to_char( dt+1, 'iw' )
          order by to_char(dt+1,'iw'))
          order by to_date( month, 'Month YYYY' ), to_number(week)
          /

          posted @ 2007-09-12 19:50 17th 閱讀(104) | 評(píng)論 (0)編輯 收藏

          僅列出標(biāo)題  
          主站蜘蛛池模板: 北碚区| 皋兰县| 寻甸| 阿拉善盟| 辽阳县| 阿荣旗| 赤壁市| 仙游县| 桐梓县| 宜兰市| 沂水县| 石屏县| 蓬莱市| 淮安市| 原阳县| 汉源县| 东乡| 陈巴尔虎旗| 马关县| 专栏| 沙田区| 庆元县| 永吉县| 临漳县| 班玛县| 大方县| 尚志市| 巍山| 防城港市| 罗山县| 海林市| 壤塘县| 铁岭市| 宝丰县| 彰化市| 陵川县| 玉林市| 富蕴县| 莱州市| 隆回县| 台江县|