CASE Statement

  • Thread starter Thread starter postmaster
  • Start date Start date
P

postmaster

I am pulling my hair out to write the following SQL Server query in
Access. What is the equivalent of CASE in access please?


SELECT [ID] ,
0.0 AS [std-deviation],
SUM( CASE
WHEN lob ="R" THEN [loss netded]
WHEN lob = "C" THEN [dam gross]
WHEN lob = "M" THEN [dam gross] END) AS LOSS
FROM tblEventLosses
 
What happens with lob isn't R, C, or M?

Either

IIf(lob = "R", [loss netded], IIf(lob = "C", [dam gross], IIf(lob = "M",
[dam gross], ?)))

or

Switch(lob = "R", [loss netded], lob = "C", [dam gross], lob = "M", [dam
gross])

Switch will return Null if none of the conditions are met.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top