SQLServer 利用Case When Then多条件判断
select top 100 State, JoinState,
(
case
when State = 1 and Joinstate = 0
then 2
when State = 1 and JoinState = 1
then 1
else 0
end
) as usestate
from UserInfo
select top 100 State, JoinState,
(
case
when State = 1 and Joinstate = 0
then 2
when State = 1 and JoinState = 1
then 1
else 0
end
) as usestate
from UserInfo