各位大虾好 小弟想请教一句SQL语句
就是我有一张表 表里面有两个字段
ID,TIME
time字段的格式是 2008/05/22 11:54:25
我想得到从当天早上9点以后 到下午5点以前 这个时间段内有多少条记录的总数
这个SQL 应该怎样写
谢谢
就是我有一张表 表里面有两个字段
ID,TIME
time字段的格式是 2008/05/22 11:54:25
我想得到从当天早上9点以后 到下午5点以前 这个时间段内有多少条记录的总数
这个SQL 应该怎样写
谢谢
and time>=trunc(sysdate)
select count(*)
from a
where time between to_date('2008-05-22 09:00:00','yyyy-mm-dd hh24:mi:ss')
and to_date('2008-05-22 15:00:00','yyyy-mm-dd hh24:mi:ss')
select count(*)
from a
where to_number(to_char(time,'hh24')) between 9 and 15 and
time between to_date('2008-05-1 09:00:00','yyyy-mm-dd hh24:mi:ss')
and to_date('2008-05-22 15:00:00','yyyy-mm-dd hh24:mi:ss')
WHERE TO_CHAR(SYSDATE,'yyyy/mm/dd hh24:mi:ss')
BETWEEN TO_CHAR(SYSDATE,'yyyy/mm/dd')||' 09:00:00'
AND TO_CHAR(SYSDATE,'yyyy/mm/dd')||' 15:00:00'
where to_char(sysdate,'hh24') between '09' and '17'
where to_char(sysdate,'hh24') between '09' and '17'