SQL 查一段时间之间的数据 比如1月份到2月份的数据

SQL查询SR表里面1月1号-2月1号服务申告总数量(scum) 和完成数量(success)后面的where条件要求时间是空或者大于我指定的那个时间 要怎么改下面那个SQL啊 请高手指点。 SQL如下
select '服务申告经理统计' as title,count(*) as scum,sum(sr.success) as success from (select ticketid,
case when s.closecode_mep != '取消' then 1 else 0 end as success from sr s
where s.closetime_mep is null or s.closetime_mep >
to_char(statusdate,'yyyy-mm-dd') between '2011-01-18' and '2011-02-18') sr
这个SQL里面的 where s.closetime_mep is null or s.closetime_mep >
to_char(statusdate,'yyyy-mm-dd') between '2011-01-18' and '2011-02-18') sr 这个运算符的大于号这里能用吗?要怎么改才对呢。

也不知道是不是你想要的内容
思路:单独用SQL求服务申告总数量(scum)和完成数量(success)然后显示到一个表里。
select
'服务申告经理统计' as title,
(
select count(*) from sr
where statusdate between '2011-01-18' and '2011-02-19'
) as scum,
(
select count(*) from sr
where statusdate between '2011-01-18' and '2011-02-19' and closetime_mep is null
)success
温馨提示:内容为网友见解,仅供参考
第1个回答  2011-02-19
select sum(quarter1),sum(quarter2),sum(quarter3),sum(quarter4)
from
(select quarter1,0 quarter2,0 quarter3,0 quarter4
from table where minute<15
union all
select 0 quarter1,quarter2,0 quarter3,0 quarter4
from table where minute>=15 and minute<30
union all
select 0 quarter1,0 quarter2,quarter3,0 quarter1
from table where minute>=30 and minute<45
union all
select 0 quarter1,0 quarter2,0 quarter3,quarter4
from table where minute>=45
)
//group by^^^^^^^^^^^^
这样查询出来的内容,第一个字段为,前十五分钟内容,第二个字段为中间十五分钟内容…………
第2个回答  2011-02-19
只需比最大时间大就行了 >dateform('2011-02-18','yyyy-mm-dd')
相似回答