日期:2014-05-18 浏览次数:20520 次
if object_id('[tb]') is not null drop table [tb]
go
create table [tb]([语文] int,[数学] int,[英语] int)
insert [tb]
select 45,70,89 union all
select 90,45,79 union all
select 89,89,89
go
select
语文=case when 语文<60 then '差' when 语文>=80 then '好' else '良' end,
数学=case when 数学<60 then '差' when 数学>=80 then '好' else '良' end,
英语=case when 英语<60 then '差' when 英语>=80 then '好' else '良' end
from tb
/**
语文 数学 英语
---- ---- ----
差 良 好
好 差 良
好 好 好
(3 行受影响)
**/
------解决方案--------------------
case when 判断一下就ok了。