我在访问2007中使用switch语句,我想知道如何指定默认值
select
switch
(
MyCol = 1, 'Value is One',
MyCol = 2, 'Value is Two'
) from MyTable
由于
答案 0 :(得分:16)
SELECT
Switch(MyTable.[MyCol]='1','Terrestrial',
MyTable.[MyCol]='2','Value is two',MyTable.[MyCol]='3','Value is three',
True,'Error') AS ColumnName
FROM MyTable;
答案 1 :(得分:14)
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
答案 2 :(得分:0)
Swich命令的语法是:
Switch(TestCase1, Result1, TestCase2, Result2, {As many more TestCases and Results as you need...}, DefaultResult)
请注意, DefaultResult 是一个可选参数,如果实际数据与任何测试用例都不匹配,则会提供响应。