select  ID,Username,namer=(case when(score<='')    then '实习'

                                when(score>''  and  score<='' )   then '赤脚医生'

                                when(score>''  and score<='' )   then '村卫生员'

                                when(score>''  and score<='' )   then '乡卫生员'

                                when(score>''  and score<='' )   then '镇卫生员'

                                when(score>''  and score<='' )   then '医师'

                                when(score>''  and score<='' )   then '主治医师'

                                when(score>''  and score<='' )   then '副主任医师'

                                when(score>''  and score<='' )   then '主任医师'

                                when(score>''  and score<='' )   then '健康大使'

                                else   '健康大使'  end )FROM  jk01_YiWen_Question
WHERE UserID = dbo.jk01_Member.ID) as questionnum

例子来源于:SQL利用Case When Then多条件判断SQL 语句

05-11 21:44