报表的棘手 SQL
我有一个包含以下四列的表格。
Student_Id
Course_Id
Seq_No
Date_Taken
寻找有关 Oracle db SQL 的任何帮助以获得以下报告。
另外,是否可以使用子查询在单个查询中获取报告?
Course_ID | CR150
=============================================
Total students Taken | 5
Students Taken this as First Course | 3
Only Course Taken by Students | 3
Students Taken 2 Courses | 2
I have a table with the following four columns.
Student_Id
Course_Id
Seq_No
Date_Taken
Looking for any help on SQL for oracle db to get the following report.
Also is it possible to get the report in a single query using sub queries?
Course_ID | CR150
=============================================
Total students Taken | 5
Students Taken this as First Course | 3
Only Course Taken by Students | 3
Students Taken 2 Courses | 2
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要执行嵌套查询。内部查询应该使用分析查询来按学生和课程进行选择、学生正在学习多少门课程以及按顺序选择哪门课程。然后,您可以在 group by 查询的 FROM 中使用它,以提供您想要的报告。
我可以给你 SQL,但我不会,因为这是你的作业问题,不是我的。但是 http://www.orafaq.com/node/55 可能会帮助您了解如何做分析查询。
You need to do a nested query. The inner query should use an analytic query to select by student and course, how many courses the student is taking, and which course this is in sequence. Then you can use that in the FROM of a group by query that gives the report that you want.
I could give you the SQL but won't because it is your homework problem, not mine. But http://www.orafaq.com/node/55 may help you learn how to do analytic queries.