34,594
社区成员
发帖
与我相关
我的任务
分享
create proc student
as
begin
select a.id,a.姓名,a.年龄,b.总分,
case when a.年龄>15 and isnull(b.总分,0)>500 then '好' else '良' end as 评定
from 学生表 a left join 成绩表 b on a.id=b.id
order by a.id
end
declare @a varchar(10),@b varchar(10)
set @a=8
set @b=15
select case when @a<@b then '对' else '错' end
/*
----
错
(1 行受影响)
*/
update 学生表
set 评定 = (case when 成绩 > 500 then '好' end)
where 年龄>'15'
select ID,(case when 成绩 > 500 then '好' end) as 评定
from 学生表
where 年龄>'15'
update 成绩表
set 评定='好'
from 学生表
where 成绩表.id=学生表.id
and 总分>500
and 年龄>'15'
update 成绩表 set 评定='好' where 总分>500
and id in(select ID from 学生表 where 年龄>'15')