听了杨老师的视频,case expression实现离散值判断,但case后面的列参数什么情况下该加参数,什么情况下不加参数呢?有点小糊涂,求解!!!在此谢过了
例如:
(1)
select (
case
when a>b then a
else b
end
),
case
when b>c then b
else c
end
)
from t
(2)
select Name,
sum((case score
when N'胜' then 1
else 0
end)) as 胜,
sum((case score
when N'负'then 1
else 0
end)) as 负,
from t_Scores
Group by Name; |