Oracle Search

Friday, June 5, 2009

Order By clause

The STUDENT_GRADES table has these columns:

STUDENT_ID NUMBER(12)
SEMESTER_END DATE
GPA NUMBER(4,3)

The registrar has requested a report listing the students grade point averages (GPA), sorted from highest grade point average to lowest within each semester, starting from the earliest date.

Which statement accomplishes this?


A.SELECT student_id, semester_end, gpa
FROM student_grades
ORDER BY semester_end DESC, gpa DESC;


B.SELECT student_id, semester_end, gpa
FROM student_grades
ORDER BY semester_end ASC, gpa ASC;


C. SELECT student_id, semester_end, gpa
FROM student_grades
ORDER BY semester_end, gpa DESC;


D. SELECT student_id, semester_end, gpa
FROM student_grades
ORDER BY gpa DESC, semester_end DESC;

Answer:C

Explanation:This answer shows correct syntax and semantics to receive desired result.

Incorrect Answers
A: Semesters will be sorted started from the oldest date, not the earliest.
B: GPA data will be sorted in ascending order, what is opposite to our task.
D: Semesters will be sorted started from the oldest date, not the earliest. Only difference with answer A is order of columns in the ORDER BY clause.

0 comments:

atchaya.com