Oracle 根据不同成绩,对应不同等级信息

1 --查询每一颗成绩的:优秀、良好、不良的数量
2 --校园需要一张各科成绩状态统计表,格式如下:
3 
4 --科目名称  优秀人数  良好人数    不良人数
5 --高等数学    5          12       2
6 --英语       8          18       1

先创建一个视图,然后把这个视图当做一个表,对这个视图进行操作

create view test
as
select cid ,case
                    when cmark >=90 then '优秀'
                    when cmark >=80 then '良好'
                    else '不良'
                    end tip
from mark m
1 select (select cname from course where cid=c.cid) 课程名,
2               (select count(*) from test t where c.cid=t.cid and t.tip='优秀' ) 优秀,
3               (select count(*) from test t where c.cid=t.cid and t.tip='良好' ) 良好,
4               (select count(*) from test t where c.cid=t.cid and t.tip='不良' ) 不良
5 from test b join course c on b.cid = c.cid
6 group by c.cid

 

posted @   勤快的懒羊羊  阅读(770)  评论(0编辑  收藏  举报
编辑推荐:
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
阅读排行:
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 单元测试从入门到精通
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 上周热点回顾(3.3-3.9)
· winform 绘制太阳,地球,月球 运作规律
点击右上角即可分享
微信分享提示