SQL 左联接+when then+子查询 综合练习

在这里插入图片描述

select stName,stage,
        英语成绩=case 
		when tenglish is null then '缺考'
		when tenglish < 60 then '不及格'
		else cast(tenglish as nvarchar)
		end,
		数学成绩=case 
		when tmath is null then '缺考'
		when tmath <60 then '不及格'
		else cast(tmath as nvarchar)
		end 
		from
(select t1.stName,t1.stAge,
t2.tEnglish,
t2.tMath
from Student as t1 
left join TblScore as t2 
on  t1.stId=t2.tSid)as t3
发布了55 篇原创文章 · 获赞 4 · 访问量 1422

猜你喜欢

转载自blog.csdn.net/BowenXu11/article/details/104731983