Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to use CASE in a SELECT clause ?

0 views
Skip to first unread message

Michel Lapointe

unread,
Jul 15, 2004, 9:38:03 AM7/15/04
to
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


Wayne Morgan

unread,
Jul 15, 2004, 9:53:58 AM7/15/04
to
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....

--
Wayne Morgan
Microsoft Access MVP


"Michel Lapointe" <a...@microsoft.com> wrote in message
news:O$DQYDnaE...@TK2MSFTNGP11.phx.gbl...

Michel Lapointe

unread,
Jul 15, 2004, 10:14:29 AM7/15/04
to
Thank...

It work well, just need to make sure to double the " in a RowSource :)

ML
"Wayne Morgan" <comprev_gothro...@hotmail.com> a écrit dans le
message de news:e09jvMna...@TK2MSFTNGP10.phx.gbl...

0 new messages