Pinku

Pinku

  • 1.4k
  • 302
  • 45.2k

How to use case condition in sql server

Aug 9 2019 12:55 AM
select AccountDID,Productslice,Productcount,LCSCount from (select coalesce (a.AccountDID,b.AccountDID) as AccountDID,a.ProductSlice,
sum(isnull(a.ProductCount,0)) ProductCount,sum(isnull(b.LCSCount,0)) LCSCount,b.RdbSliceCode from #ProductAudit a
full outer join #LCSAudit b on a.AccountDID=b.AccountDID and a.ProductSlice=b.RdbSliceCode
group by a.AccountDID,b.AccountDID,a.ProductSlice,b.RdbSliceCode)a where LCSCount<>ProductCount
here #ProductAudit table contain one column i.e levelCapability and #LCSAudit contain one column i.e usergroupname
So i want to use case in above query like..the condition is..
if in #ProductAudit table ...levelCapability =="recruitment" and in #LCSAudit table ..... usergroupname==null than i want to select the account did..
How can i do it?

Answers (3)