Cracking the coding interview--Q15.5
来源:互联网 发布:管家婆软件安装 编辑:程序博客网 时间:2024/05/18 03:31
题目
原文:
Imagine a simple database storing information for students’ grades. Design what this database might look like, and provide a SQL query to return a list of the honor roll students (top 10%), sorted by their grade point average.
译文:
假设有一个简单的数据库,存储学生的成绩,设计这样的一个数据库:提供sql的查询光荣榜列表的前%10的学生的信息,并按照他们的GPA 排序。
解答
在一个简单的数据库中,我们至少需要以下三张表:学生表(Students),课程表(Courses), 及课程登记表(CourseEnrollment)。学生表中至少需要有学生姓名和学生ID, 及其它的个人信息。课程表包含课程名和课程ID,还可以包含课程描述和授课老师等。 课程登记表将包含学生和课程对(即哪个学生选了什么课,某课程有哪些学生选), 还包含课程成绩等。我们假设课程成绩是一个整数。
获取光荣榜学生的SQL语句如下:
SELECT StudentName, GPAFROM ( SELECT top 10 percent Avg(CourseEnrollment.Grade) AS GPA, CourseEnrollment.StudentID FROM CourseEnrollment GROUP BY CourseEnrollment.StudentID ORDER BY Avg(CourseEnrollment.Grade)) HonorsINNER JOIN Students ON Honors.StudentID = Students.StudentID
更多数据库练习:http://blog.csdn.net/zbdba/article/details/16806937
---EOF---
0 0
- Cracking the coding interview--Q15.5
- Cracking the coding interview--Q15.1
- Cracking the coding interview--Q15.2
- Cracking the coding interview--Q15.3
- Cracking the coding interview--Q15.4
- Cracking the Coding Interview
- 《Cracking the coding interview》
- Cracking The Coding Interview
- Cracking the coding interview
- Cracking the coding interview
- Cracking the coding interview--Q2.5
- Cracking the Coding Interview Chap1 Q1.5
- Cracking the coding interview--Q1.5
- Cracking the coding interview--Q1.5
- Cracking the coding interview--Q2.5
- Cracking the coding interview--Q3.5
- Cracking the coding interview--Q4.5
- Cracking the coding interview--Q5.5
- ui.popover 一个轻量级AngularJS表单验证提示解决方案
- android bitmap compress(图片压缩)
- 第四周作业-多线程编程
- 推拉踢拽,都不会倒下的电动摩托
- 图像的灰度共生矩阵
- Cracking the coding interview--Q15.5
- 【爱上cocos2d-x之十】动作Action
- 杭电OJ 1030:Delta-wave
- 第四周作业-多线程编程
- Hadoop的思想起源--Google
- java学习笔记(四)-- 实践篇
- 学了三年的PS 全部在这里了,都是精华(photoshop常用操作)
- 标签taglib prefix
- grread捕捉