SQL查询时出现“将字符串转换为 uniqueidentifier 时失败”。 select a.CustomerName,a.boy,b.girl from (select c.CustomerName,count(*) as boy from tb_masEmPersonalInfo a left join tb_masEmployeeEmployer b on a.EmPersonalInfoID=b.EmPersonalInfoID left join tb_masCustomer c on b.CustomerID=c.CustomerID where a.Disabled=0 and b.EwStatus in ('A','N') and a.GenderID=1 and c.CustomerID='@c.CustomerID' group by c.CustomerName) a left join (select c.CustomerName,count(*) as girl from tb_masEmPersonalInfo a left join tb_masEmployeeEmployer b on a.EmPersonalInfoID=b.EmPersonalInfoID left join tb_masCustomer c on b.CustomerID=c.CustomerID where a.Disabled=0 and b.EwStatus in ('A','N') and a.GenderID=2 and c.CustomerID='@c.CustomerID' group by c.CustomerName) b on a.CustomerName=b.CustomerName
union
select '总计' as CustomerName,a.boy as 男,b.girl as 女 from (select count(*) as boy from tb_masEmPersonalInfo a left join tb_masEmployeeEmployer b on a.EmPersonalInfoID=b.EmPersonalInfoID left join tb_masCustomer c on b.CustomerID=c.CustomerID where a.Disabled=0 and b.EwStatus in ('A','N') and a.GenderID=1 and c.CustomerID='@c.CustomerID') a left join (select count(*) as girl from tb_masEmPersonalInfo a left join tb_masEmployeeEmployer b on a.EmPersonalInfoID=b.EmPersonalInfoID left join tb_masCustomer c on b.CustomerID=c.CustomerID where a.Disabled=0 and b.EwStatus in ('A','N') and a.GenderID=2 and c.CustomerID='@c.CustomerID') b on 1=1