SWITCH command in SQL statement

  • Thread starter Thread starter Island_Dude via AccessMonster.com
  • Start date Start date
I

Island_Dude via AccessMonster.com

Hello experts,

I'm trying to figure out the right syntax to do the following in SQLt:

if Field_Country is equal to USA switch to "Y" as Address,

if Field_Country is not to equal to USA switch to "Z" as Address,


I try the following syntax but it's not working:
...........................

SWITCH(Field_Country = USA, Y, Field_Country <> USA, Z) As Address
...........................

Any suggestion on how I can fix this or any method I could use to do that.

Thanks for your help
 
Hello experts,

I'm trying to figure out the right syntax to do the following in SQLt:

if Field_Country is equal to USA switch to "Y" as Address,

if Field_Country is not to equal to USA switch to "Z" as Address,

I try the following syntax but it's not working:
..........................

SWITCH(Field_Country = USA, Y, Field_Country <> USA, Z) As Address
..........................

Any suggestion on how I can fix this or any method I could use to do that.

Thanks for your help

Strings need to be surrounded with quotes.

SWITCH([Field_Country] = "USA", "Y", [Field_Country] <> "USA", "Z") As
Address

Why not a simpler IIF Statement?

IIf([Field_Control] = "USA","Y","N") as Address
 
Back
Top