SQL如何将几条语句查询结果求和

select ISNULL(sum(case when totalweightlimit=17000 and overloadweight>170 then vehcount else 0 end),0)一型,ISNULL(sum(case when totalweightlimit=25000 and overloadweight>250 then vehcount else 0 end),0)二型,ISNULL(sum(case when totalweightlimit=35000 and overloadweight>350 then vehcount else 0 end),0)三型,ISNULL(sum(case when totalweightlimit=43000 and overloadweight>430 then vehcount else 0 end),0)四型,ISNULL(sum(case when totalweightlimit=49000 and overloadweight>490 then vehcount else 0 end),0)五型from LaneExList where squaddate between '20171101'and'20171130'and exvehicleflag=2各位高手,以上语句是我平常查询使用的语句。我现在是想在FROM前加一条求和语句,目的把以上的“一型”至“五型”这五条语句的查询结果进行求和。感谢各位!

select ä¸€åž‹,。。。,五型,   ä¸€åž‹+...+五型  as å’Œ
from(
select ISNULL(sum(case when totalweightlimit=17000 and overloadweight>170 then vehcount else 0 end),0)一型,ISNULL(sum(case when totalweightlimit=25000 and overloadweight>250 then vehcount else 0 end),0)二型,ISNULL(sum(case when totalweightlimit=35000 and overloadweight>350 then vehcount else 0 end),0)三型,ISNULL(sum(case when totalweightlimit=43000 and overloadweight>430 then vehcount else 0 end),0)四型,ISNULL(sum(case when totalweightlimit=49000 and overloadweight>490 then vehcount else 0 end),0)五型from LaneExList where squaddate between '20171101'and'20171130'and exvehicleflag=2
) abc
温馨提示:答案为网友推荐,仅供参考
相似回答