SQL 查一段时间之间的数据 比如1月份到2月份的数据
SQL查询SR表里面1月1号-2月1号服务申告总数量(scum)和完成数量(success)后面的where条件要求时间是空或者大于我指定的那个时间要怎么改下面那个SQL...
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 这个运算符的大于号这里能用吗?要怎么改才对呢。 展开
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 这个运算符的大于号这里能用吗?要怎么改才对呢。 展开
3个回答
展开全部
也不知道是不是你想要的内容
思路:单独用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
思路:单独用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
展开全部
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^^^^^^^^^^^^
这样查询出来的内容,第一个字段为,前十五分钟内容,第二个字段为中间十五分钟内容…………
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^^^^^^^^^^^^
这样查询出来的内容,第一个字段为,前十五分钟内容,第二个字段为中间十五分钟内容…………
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
只需比最大时间大就行了 >dateform('2011-02-18','yyyy-mm-dd')
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询