JAVA—咖啡館

          ——歡迎訪問rogerfan的博客,常來《JAVA——咖啡館》坐坐,喝杯濃香的咖啡,彼此探討一下JAVA技術,交流工作經驗,分享JAVA帶來的快樂!本網站部分轉載文章,如果有版權問題請與我聯系。

          BlogJava 首頁 新隨筆 聯系 聚合 管理
            447 Posts :: 145 Stories :: 368 Comments :: 0 Trackbacks

          當月數據

          Sql代碼
          1. select * from table t   
          2. where t.create_time >=TRUNC(SYSDATE, 'MM')   
          3. and t.create_time<=last_day(SYSDATE)  
          select * from table t
          where t.create_time >=TRUNC(SYSDATE, 'MM')
          and t.create_time<=last_day(SYSDATE)


          當年數據

          Sql代碼
          1. select * from table t   
          2. where t.create_time >=trunc(sysdate,'YYYY')   
          3. and t.create_time<=add_months(trunc(sysdate,'YYYY'),12)-1  
          select * from table t
          where t.create_time >=trunc(sysdate,'YYYY')
          and t.create_time<=add_months(trunc(sysdate,'YYYY'),12)-1


          本周(國外周日為一個星期第一天)

          Sql代碼
          1. where t.create_time >=trunc(sysdate,'day')+1 and t.create_time<=trunc(sysdate,'day')+6   
          where t.create_time >=trunc(sysdate,'day')+1 and t.create_time<=trunc(sysdate,'day')+6


          本周(國內周一為一個星期第一天)

          Sql代碼
          1. where t.create_time >=trunc(next_day(sysdate-8,1)+1) and t.create_time<=trunc(next_day(sysdate-8,1)+7)+1  

          posted on 2010-07-13 10:23 rogerfan 閱讀(440) 評論(0)  編輯  收藏 所屬分類: 【數據庫】
          主站蜘蛛池模板: 澎湖县| 锦州市| 汕尾市| 米林县| 湘潭市| 望都县| 仪陇县| 松江区| 中超| 米易县| 广南县| 莫力| 乌什县| 宜兰县| 东乡族自治县| 瑞丽市| 正安县| 日照市| 上杭县| 东乌| 全州县| 启东市| 土默特左旗| 鄂托克前旗| 温泉县| 濮阳市| 嘉定区| 崇阳县| 澜沧| 瑞安市| 奉节县| 九台市| 屏南县| 北流市| 广安市| 安龙县| 平果县| 鲁山县| 丹江口市| 宣恩县| 惠安县|