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