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

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