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)
FROM jk01_YiWen_Question WHERE UserID = dbo.jk01_Member.ID) as questionnum from jk01_Member
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)
FROM jk01_YiWen_Question WHERE UserID = dbo.jk01_Member.ID) as questionnum from jk01_Member