请教SQL语句错在哪里???
1、执行以下查询语句时出现“在关键字 'Union' 附近有语法错误。”,不知如何更正错误???2、以下查询语句为了实现在最后一行统计 FuKuanJinE 字段之和,请问能否精简一下代码??
谢谢大家!
select
HeTongXinXi.HeTongID,HeTongBianHao,HeTongMingCheng,YiFangDanWei,convert(varchar(10),FuKuanShiJian,120) as FuKuanShiJian,FuKuanJinE
from HeTongXinXi
right join ShiGongHeTongFuKuanDengJi on HeTongXinXi.HeTongID=ShiGongHeTongFuKuanDengJi.HeTong_ID
where XiangMuMingChenID like '%1/2/3/11%' order by HeTongBianHao
Union all
select
null as HeTongID,总计 as HeTongBianHao,null as HeTongMingCheng,null as YiFangDanWei,null as FuKuanShiJian,sum(FuKuanJinE) as FuKuanJinE
from HeTongXinXi
right join ShiGongHeTongFuKuanDengJi on HeTongXinXi.HeTongID=ShiGongHeTongFuKuanDengJi.HeTong_ID
where XiangMuMingChenID like '%1/2/3/11%'