SQL Server基本操作练习
原创
©著作权归作者所有:来自51CTO博客作者流楚丶格念的原创作品,请联系作者获取转载授权,否则将追究法律责任
代码实现:
use test_0425
go
select *from student
select *from student
where stspecialty like'%学'
select *from student
where stscore like '[7-8][2-7]' and stspecialty like'_文' and stsex is not null
select *from student
where stscore between 72 and 87 and stno in(4,10,17)
order by stscore desc
select stno , stname from student
where exists(select *from student where stsex='女')
select stsex as '性别' ,count(stsex) as '数量' , avg(stscore) as '平均分', sum(stscore) as 总分 from student
group by stsex
select *,
评价=case
when stscore>=90 then '优秀'
when stscore>=80 and stscore <90 then '良好'
when stscore>=70 and stscore <80 then '可以'
when stscore>=60 and stscore <70 then '加油'
when stscore>=1 and stscore <60 then '加油'
else '牛逼'
end
from student
order by stscore desc
结果实现: