Oracle取某時間段的資料

來源:互聯網
上載者:User

Oracle取某時間段的資料:

sysdate+1是加一天,sysdate+/-(1/48)就是加/減 半個小時

select count(*) from table_name where table_name.date between to_char(sysdate-1/48,'yyyymmdd HH:mi') and sysdate

其中date為你要統計的欄位名字

table_name為表的名字

to_char是一個日期函數 to_char(sysdate,'yyyymmdd HH:mi') 為截取到分鐘,對應的to_char(sysdate,'yyyymmdd HH')為截取到小時。to_char(sysdate,'yyyymm')為截取到月份,

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.