oracle中查询某段日期内的某个时间段的语句
(2011-08-29 16:04:17)select bbb ,count(bbb) from (
select * from aaa
where
rec_date between
trunc(to_date('2011-8-22 09:00:00','yyyy-mm-dd hh24:mi:ss'))
and
trunc(to_date('2011-8-25 09:00:00','yyyy-mm-dd hh24:mi:ss'))
and
to_char( aaa.bbb, 'hh24:mi:ss') between '09:00:00' and'10:00:00')
group by bbb
如果是两个不同的表,确定其结构是否相同,使用union进行比较
select bbb ,count(bbb) from (
如果是两个不同的表,确定其结构是否相同,使用union进行比较
select * from aaa
where
rec_date between
trunc(to_date('2011-8-22 09:00:00','yyyy-mm-dd hh24:mi:ss'))
and
trunc(to_date('2011-8-25 09:00:00','yyyy-mm-dd hh24:mi:ss'))
union
select * from aaa
where
to_char( aaa.bbb, 'hh24:mi:ss')between
'09:00:00' and'10:00:00')
where
to_char( aaa.bbb, 'hh24:mi:ss')between
group by bbb
本文介绍如何在Oracle数据库中查询特定日期范围内某个时间段的数据,并提供实际示例,包括使用to_date, to_char等函数来筛选记录。

被折叠的 条评论
为什么被折叠?



