数据库报表
SELECT rownumber() over(order by alldays desc,usercode) as rownum, z.code,z.type1,substr(z.endtime,1,10) as endtime,z.alldays,b.name,b.ocode,c.manufacturer,d.usercode,d.wdname,d.azdate ,d.bxdate ,d.status from (
select a.code,a.type1,max(a.endtime) as endtime,days(current date) - days(cast(substr(max(a.endtime),1,10) as date)) as alldays from pm_vwgj a
group by a.code,a.type1 ) as z
left join atm_type c on z.type1=c.tcode,bank b,sb_t d where d.usercode=b.bankcode and z.code=d.code and z.type1=d.type1
and (d.status='运行' or d.status='暂停' ) and d.pmconcernstatus<>2
and z.alldays >=60
and not exists (select * from atm_bank_right s where s.bankcode=d.usercode and righttype=2);
与
SELECT rownumber() over(order by alldays desc,usercode) as rownum, z.code,z.type1,substr(z.endtime,1,10) as endtime,z.alldays,b.name,b.ocode,c.manufacturer,d.usercode,d.wdname,d.azdate ,d.bxdate ,d.status from (
select a.code,a.type1,max(a.endtime) as endtime,days(current date) - days(cast(substr(max(a.endtime),1,10) as date)) as alldays from pm_vwgj a
group by a.code,a.type1 ) as z
left join atm_type c on z.type1=c.tcode,bank b,sb_t d where d.usercode=b.bankcode and z.code=d.code and z.type1=d.type1
and (d.status='运行' or d.status='暂停' ) and d.pmconcernstatus<>2
and z.alldays >=60
and exists (select * from atm_bank_right s where s.bankcode=d.usercode and righttype=2);
为什么第一个消耗的时间要比第二个长好多啊?