我在 access 2007 中使用 switch 语句,我想知道如何指定默认值
select
switch
(
MyCol = 1, 'Value is One',
MyCol = 2, 'Value is Two'
) from MyTable
谢谢
我在 access 2007 中使用 switch 语句,我想知道如何指定默认值
select
switch
(
MyCol = 1, 'Value is One',
MyCol = 2, 'Value is Two'
) from MyTable
谢谢
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
参考:
http://www.utteraccess.com/forum/Switch-statement-default-t453140.html
Swich 命令的语法是:
Switch(TestCase1, Result1, TestCase2, Result2, {As many more TestCases and Results as you need...}, DefaultResult)
请注意,DefaultResult是一个可选参数,如果实际数据与任何测试用例都不匹配,它将提供响应。