Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

COSC 4336: Database Systems 9. Execute a SQL statement to display, in descending

ID: 672262 • Letter: C

Question

COSC 4336: Database Systems

9. Execute a SQL statement to display, in descending order, the names of

the students who are enrolled in the Soccer Club.

10. Execute a SQL statement to display the student’s last name and his or her

mentor’s name for the student whose id is 12153 with a UNION statement.

11. Execute a SQL statement to display the mentor name(s) of the student(s)

who has (have) the last name Smith.

12. Execute a SQL statement to display the first name(s) and last name(s) of

the student(s) whose mentor is Smith and who is (are) enrolled in the

Book Club.

13. Execute a nested query statement to display the student ids and club names

of the students who are recruiters and pay less than $100 for membership

fees.

14. By using the EXISTS operator, execute a SQL statement to display the

first and last names of the students who are enrolled in the Book Club.

Explanation / Answer

9.
The order by clause is used to sort the query result sets in descending order.
It is used in conjunction with the SELECT query.

The DESC sort keyword has the following basic syntax.

SELECT {fieldName(s) | *} FROM tableName(s) [WHERE condition] ORDER BY fieldname(s) DESC [LIMIT N]

HERE

SELECT {fieldName(s) | *} FROM tableName(s) is the statement containing the fields and table(s) from which to get the result set from.
[WHERE condition] is optional but can be used to filter the data according to the given condition.
ORDER BY fieldname(s) is mandatory and is the field on which the sorting is to be performed. The DESC keyword specifies that the sorting is to be in descending order.
[LIMIT] is optional but can be used to limit the number of results returned from the query result set.

**The names of the students who are enrolled in the Soccer Club.

  
SELECT * FROM students;

Executing the above script in MySQL workbench against the myflixdb gives you the desired output.