Multiple choice technology databases

The Student_Grades table has these columns: STUDENT_ID NUMBER(12) SEMESTER_END DATE GPA NUMBER(4,3) The registrar has asked for a report on the average grade point average (GPA), sorted from the highest grade point average to each semester, starting from the earliest date. Which statement will accomplish 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, gpa ASC order by semester_end DESC, gpa DESC; C. SELECT Student_id, semester_end, gpa from student_grades order by semester_end DESC, gpa ASC; D. SELECT Student_id, semester_end, gpa from student_grades order by semester_end ASC, gpa ASC; E. SELECT Student_id, semester_end, gpa from student_grades order by semester_end DESC, gpa ASC;

  1. A

  2. B

  3. C

  4. E

Reveal answer Fill a bubble to check yourself
D Correct answer
AI explanation

To answer this question, you need to understand how the ORDER BY clause works in SQL. The ORDER BY clause is used to sort the result set based on one or more columns.

Let's go through each option to understand why it is correct or incorrect:

Option A) SELECT Student_id, semester_end, gpa FROM student_grades ORDER BY semester_end DESC, gpa DESC; This option sorts the result set by semester_end in descending order and then by gpa in descending order. However, the question specifically asks for sorting by semester_end in ascending order and then by gpa in ascending order. Therefore, this option is incorrect.

Option B) SELECT Student_id, semester_end, gpa FROM student_grades ORDER BY semester_end, gpa ASC ORDER BY semester_end DESC, gpa DESC; This option has two ORDER BY clauses, which is not valid in SQL. The second ORDER BY clause should be removed. Additionally, the sorting order is incorrect as it sorts semester_end in ascending order and gpa in ascending order, while the question asks for sorting semester_end in ascending order and gpa in descending order. Therefore, this option is incorrect.

Option C) SELECT Student_id, semester_end, gpa FROM student_grades ORDER BY semester_end DESC, gpa ASC; This option sorts the result set by semester_end in descending order and then by gpa in ascending order. However, the question asks for sorting semester_end in ascending order and gpa in descending order. Therefore, this option is incorrect.

Option D) SELECT Student_id, semester_end, gpa FROM student_grades ORDER BY semester_end ASC, gpa ASC; This option sorts the result set by semester_end in ascending order and then by gpa in ascending order, which matches the requirements of the question. Therefore, this option is correct.

Option E) SELECT Student_id, semester_end, gpa FROM student_grades ORDER BY semester_end DESC, gpa ASC; This option sorts the result set by semester_end in descending order and then by gpa in ascending order. However, the question asks for sorting semester_end in ascending order and gpa in descending order. Therefore, this option is incorrect.

The correct answer is D) Option D. This option is correct because it sorts the result set by semester_end in ascending order and then by gpa in ascending order, which matches the requirements of the question.