复杂SQL

数据库 来源:myflyingangel2016 43℃ 0评论

CASE:

select STR_TO_DATE(concat(recordTim,daytime+1),'%X%V%w') as recordTime,

       seccessNum,failureNum,totalNum 
 from (select yearweek(visitTime)  as recordTim,
weekday(visitTime) as daytime, 
sum(case when visitStatus=1 then 1 else 0 end) as seccessNum, 
              sum(case when visitStatus=0 then 1 else 0 end) as failureNum ,
              count(*) as totalNum 
              from kbs_applog 
              where accessSecret="12d5ew5d66gf" 
                and visitTime > "2016-12-16 11:11:06.0" 
                and  visitTime < "2016-12-20 11:16:06.0" 
                group by recordTim) as temtable 
   limit 0,10
关闭

IT问道推荐

银行贷款频频被拒?
“Dr信用牛牛”让你远离信用污点 国内首家信用健康管理平台免费为你提供信用修复方案