报表的棘手 SQL

发布于 2024-10-16 20:38:49 字数 449 浏览 3 评论 0原文

我有一个包含以下四列的表格。

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

瑾兮 2024-10-23 20:38:49

您需要执行嵌套查询。内部查询应该使用分析查询来按学生和课程进行选择、学生正在学习多少门课程以及按顺序选择哪门课程。然后,您可以在 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文