Manas Sahu

Manas Sahu

  • 1.7k
  • 191
  • 8.9k

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?

Brought to you by: JavaScript SDK for Bold BI dashboard and analytics embedding. Free trial.

Answers (3)