以下案例陈述有效,返回Yes,col1
的值= 1。如何在col2
?
SELECT CASE
WHEN col1= '1' THEN 'Yes' ELSE 'No' END
FROM PROVIDERS
WHERE NAME = 'Hospital1'
以下给出了错误
SELECT CASE
(WHEN col1= '1' THEN 'Yes' ELSE 'No' END) as 1st,
(WHEN col2= '1' THEN 'Yes' ELSE 'No' END) as 2nd
FROM PROVIDERS
WHERE NAME = 'Hospital1'
答案 0 :(得分:2)
CASE
SELECT
CASE WHEN col1 = '1' THEN 'Yes' ELSE 'No' END AS 1st,
CASE WHEN col2 = '1' THEN 'Yes' ELSE 'No' END AS 2nd
FROM PROVIDERS
WHERE NAME = 'Hospital1'
答案 1 :(得分:2)
格式正确:
SELECT CASE
WHEN col1 = '1'
THEN 'Yes'
ELSE 'No'
END AS 1st
,CASE
WHEN col2 = '1'
THEN 'Yes'
ELSE 'No'
END AS 2nd
FROM PROVIDERS
WHERE NAME = 'Hospital1'