CASE Statement

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
 
D

Douglas J. Steele

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.
 
Top