我是一名在SQL方面经验有限的程序员。但实质上我想要做的就是
$1 = " 1 July 2010"
我的输出:
SELECT * FROM yesnomaybe_table;
我想要的输出:
yesnomaybe
----------
0
1
2
1
我已经调查了像
这样的CASEyesnomaybe
----------
45
64
55
64
但我的输出是这样的:
SELECT yesnomaybe,
CASE WHEN yesnomaybe = 0 THEN 45
WHEN yesnomaybe = 1 THEN 64
ELSE 55
END
FROM yesnomaybe_table;
我该如何解决这个问题?
答案 0 :(得分:2)
你想要这样的东西:
SELECT
CASE WHEN yesnomaybe = 0 THEN 45
WHEN yesnomaybe = 1 THEN 64
ELSE 55
END as yesnomaybe
FROM yesnomaybe_table;
在您的示例中,您选择的是yesnomaybe,然后执行没有名称的切换。