+ -
当前位置:首页 → 问答吧 → 请教各位,我想查询(比如,字段create_date) 2011-12-09 7点到8点的前10条 和 9点到10点的前10条 等等,这个SQL怎么写?

请教各位,我想查询(比如,字段create_date) 2011-12-09 7点到8点的前10条 和 9点到10点的前10条 等等,这个SQL怎么写?

时间:2011-12-11

来源:互联网

请教各位,如果我想查询一个时间字段的 2011-12-09 号的 7点到8点的前10条 、 9点到10点的前10条 、11点到12点的前10条 等等,总共30条,这个SQL咋写?

作者: dwk126   发布时间: 2011-12-11

select t.*,t.rownum from tablename t where time >= '2011-12-09 07%' and time <= '2011-12-09 08%' and t.rownum<=10
UNION ALL
select t.*,t.rownum from tablename t where time >= '2011-12-09 09%' and time <= '2011-12-09 10%' and t.rownum<=10
UNION ALL
select t.*,t.rownum from tablename t where time >= '2011-12-09 11%' and time <= '2011-12-09 12%' and t.rownum<=10

作者: mizuho_2006   发布时间: 2011-12-11