啥也不说了,直接上这个我迄今为止写过的最复杂的sql吧:
(select count(*) from select * from $tableName[]$ t11 where t11.$groupBy$=t1.$groupBy$ and serverity ]]>${serverity_high}) as highServeCount , (select count(*) fromselect * from $tableName[]$ t11 where t11.$groupBy$=t1.$groupBy$ and serverity ]]>${serverity_low} and serverity ${serverity_high}) as midServeCount , (select count(*) fromselect * from $tableName[]$ t11 where t11.$groupBy$=t1.$groupBy$ and serverity ${serverity_low}) as lowServeCount ,
0 as highServeCount, 0 as midServeCount, 0 as lowServeCount, sum(t1.sponsorNum) as sponsorNum , sum(t1.victimNum) as victimNum, t2.domainId as groupId, t6.domainName as groupName, t1.insertTstamp as timestamp fromselect * from $tableName[]$ t1 left join ( select neId,neName,sn,domainId from h_db.t_NeInfo) t2 on (t1.neId=t2.neId ) left join (select neId,ifId,name from h_db.t_IfInfo) t3 on (t1.neId=t3.neid and t1.ifId=t3.ifId) left join (select domainId,domainName from h_db.t_Domain) t6 on t2.domainId=t6.domainIdt1.neId=#neId:INTEGER# t2.domainId=#groupId:INTEGER# t3.name=#ifName# t1.neId in #neList[]# t2.domainId in #groupList[]# t1.insertTstamp= ]]>#beginTime:TIMESTAMP# t1.insertTstamp#endTime:TIMESTAMP# group by $groupBy$ order by $orderBy$ limit #topN:INTEGER#