## 一道强力SQL题-难难难

 sum plat logTime 60.1 A 2014/4/10 10 B 2014/4/10 447 E 2014/4/11 911 E 2014/4/13 4 F 2014/4/22

 sum plat logTime 60.1 A 2014/4/10 0 A 2014/4/11 0 A 2014/4/13 0 A 2014/4/22 10 B 2014/4/10 0 B 2014/4/11 0 B 2014/4/13 0 B 2014/4/22 0 E 2014/4/10 447 E 2014/4/11 911 E 2014/4/13 0 E 2014/4/22 0 F 2014/4/10 0 F 2014/4/11 0 F 2014/4/13 4 F 2014/4/22

0

select sum(case when a.logTime = b.logTime and a.plat=b.plat and a.sum=b.sum then a.sum  else 0 end) as 'sum',a.plat,b.logTime

from test a  join test b

group by a.plat,b.logTime order by a.plat,b.logTime

0
cross jion 不就搞定啦？？

0

0

select case when sum is null then 0 else sum end as 'sum' ,plat,logTime  from (select plat,logTime from(select plat from table group by plat),(select logTime from table group by table)) t1 left join table t2 on t1.plat=t2.plat and t1.logTime=t2.logTime

0
select max(if(t1.sum=t2.sum,t1.sum,0)) sum,t1.plat,t2.logTime from test t1 CROSS join test t2 GROUP BY t1.plat,t2.logTime ORDER BY t1.plat,t2.logTime

0
select sum(t4.sum2) sum3,t4.plat,t4.logtime2 from(select case t.logtime when t3.logtime2 then t.sum
else 0 end sum2, t.plat,t3.logtime2
from test t,(select t2.logtime logtime2 from test t2 group by t2.logtime) t3
)t4 group by t4.plat,t4.logtime2 order by t4.plat,t4.logtime2;