oracle查询两个时间段之间的数据,oracle时间段间数据查询(须修改)

时间段间数据查询 //返回当天的数据 select d.device_name as 设备,d.alert_time 时间 from device d whe

时间段间数据查询

//返回当天的数据

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')

获取某一天的数据

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