獲取某一天的資料
select d.device_name as 裝置,d.alert_time 時間 from device d where d.alert_time
between to_date('2010-9-27 00:00:00','yyyy-mm-dd hh24:mi:ss') and
to_date('2010-9-27 23:59:59','yyyy-mm-dd hh24:mi:ss')
//返回當天的資料
select d.device_name as 裝置,d.alert_time 時間 from device d where d.alert_time
between to_date(to_char(sysdate,'yyyy-mm-dd'),'yyyy-mm-dd hh24:mi:ss') and
sysdate;
--按照每月進行統計
select to_char(sysdate,'mm') from dual group by to_char(sysdate,'mm')
--按照每季度進行統計
select to_char(sysdate,'q') from dual group by to_char(sysdate,'q')
--按照每週度進行統計
select to_char(sysdate,'ww') from dual group by to_char(sysdate,'ww')
--按照每年進行統計
select to_char(sysdate,'yyyy') from dual group by to_char(sysdate,'yy')
分時間段查詢
declare t table 時間 datetime,金額 int insert t select 2007 1 1 10 00 23 8 union all select 2007 1 1 01 00 04 4 union all select 2007 1 1 01 00 14 4 union...
SQL時間段查詢
access的話 select from table where date1 2008 1 20 and date2 2007 8 30 mysql的話 select from table where date1 2008 1 20 and date2 2007 3 30 也可以 select fr...
SQL時間段查詢
sql時間段查詢 access的話 select from table where date1 2008 1 20 and date2 2007 8 30 mysql的話 select from table where date1 2008 1 20 and date2 2007 3 30 也可以 ...