when you USE aggregate function you need to USE group by clause after END of your where clause
select p.CompanyName,p.ResidentialAddress 'Address',p.DateOfBirth,p.Age,p.PhoneNo,p.MobileNo,p.Education,
pr.Profession,Lst.StateName 'Living State',Lct.StateName 'Living City',Nst.StateName 'Native State',
Nct.StateName 'Native City',f.FatherName,f.MotherName,
sum(cast(f.BrotherMarried as int))+sum(cast(f.BrotherUnmarried as int)) as TotalBrothers,
sum(cast(f.BrotherMarried as int))+sum(cast(f.BrotherUnmarried as int)) as TotalSisters
from personalinfo p
left outer join Profession pr on p.Profession=pr.id
left outer join state Nct on p.NativeCityId=Nct.id
left outer join state Nst on p.NativeStateId=Nst.id
left outer join state Lct on p.LivingCityId=Lct.id
left outer join state Lst on p.LivingStateId=Lst.id
left outer join familydetails f on f.customerid=p.customerid
where p.CustomerId='a1a57b79-6585-406f-a5a0-53cf7b9f3f60'
GROUP BY p.CompanyName,p.ResidentialAddress 'Address',p.DateOfBirth,p.Age,p.PhoneNo,p.MobileNo,p.Education,
pr.Profession,Lst.StateName 'Living State',Lct.StateName 'Living City',Nst.StateName 'Native State',
Nct.StateName 'Native City',f.FatherName,f.MotherName
Sandeep M,
Software Developer
Follow me on :
http://sandeepmhatre.blogspot.in
Self-Innovator, if this helps please login to Mark As Answer. | Alert Moderator