How to use CASE in a SELECT clause ?

  • Thread starter Thread starter Michel Lapointe
  • Start date Start date
M

Michel Lapointe

Hello,

Does anyone know if it's possible in access to replicate this kind of
SQL query?

select CASE CategoryID
WHEN 1 THEN 'Value 1'
WHEN 2 THEN 'Value 2'
ELSE 'Value Not Defined'
END AS DiscountPrice
from categories


Thank

Michel Lapointe
 
You can use nested IIf statements or a Choose statement.

Example:
SELECT IIf(CategoryID=1, "Value 1", IIf(CategoryID=2, "Value 2", "Value Not
Defined")) AS DiscountPrice FROM Categories....
 
Back
Top