select
nameLast + ',' + nameFirst as 'Name'
from
Players
CASE
WHEN bats = 'L' THEN 'Left'
WHEN bats = 'R' THEN 'Right'
WHEN bats = 'B' THEN 'Both'
ELSE 'Unknown'
END AS bats
FROM Players
为什么“ case”出现语法错误?我看过其他例子,这不是错误。我想念的是什么?
答案 0 :(得分:1)
除非您没有case expression
子句,否则您不应该在FROM
之后加上WHERE
。
SELECT
nameLast + ',' + nameFirst as 'Name',
CASE
WHEN bats = 'L' THEN 'Left'
WHEN bats = 'R' THEN 'Right'
WHEN bats = 'B' THEN 'Both'
ELSE 'Unknown'
END AS bats
FROM Players