I am using switch statement in access 2007, i want to know how I can specify default value
select
switch
(
MyCol = 1, 'Value is One',
MyCol = 2, 'Value is Two'
) from MyTable
Thanks
I am using switch statement in access 2007, i want to know how I can specify default value
select
switch
(
MyCol = 1, 'Value is One',
MyCol = 2, 'Value is Two'
) from MyTable
Thanks
SELECT
Switch(MyTable.[MyCol]='1','Terrestrial',
MyTable.[MyCol]='2','Value is two',MyTable.[MyCol]='3','Value is three',
True,'Error') AS ColumnName
FROM MyTable;
select
switch
(
MyCol = 1, 'Value is One',
MyCol = 2, 'Value is Two'
True,"Default"
) from MyT
Refer:
http://www.utteraccess.com/forum/Switch-statement-default-t453140.html
The syntax for the Swich command is:
Switch(TestCase1, Result1, TestCase2, Result2, {As many more TestCases and Results as you need...}, DefaultResult)
Note that the DefaultResult is an optional parameter and will provide a response in the event that the actual data does not match any of the Test Cases.