case end进行多条件的判断
--查看Person表 select * from Person

--对math字段进行条件判断 select name,数学成绩= case when math>100 then ‘优‘ when math>90 then ‘良‘ when math>80 then ‘中‘ when math>70 then ‘及格‘ when math is NULL then ‘缺考‘ else ‘不及格‘ end from Person
结果:

--查询t8表 select * from t8

--对相邻两个表的值进行大小判断 select A与B列中的最大值= case when A>B then A else B end, B与C列中的最大值= case when B>C then B else C end from t8
结果:

原文:http://www.cnblogs.com/wuqiuxue/p/7679568.html