Examveda

If emp_id contain the following set {9, 7, 6, 4, 3, 1, 2}, what will be the output on execution of the following MySQL command?
SELECT emp_id
FROM person
ORDER BY emp_id DESC;

A. {9, 7, 6, 4, 3, 1, 2}

B. {1, 2, 3, 4, 6, 7, 9}

C. {2, 1, 3, 4, 6, 7, 9}

D. None of the mentioned

Answer: Option A

Solution (By Examveda Team)

This question is about how MySQL sorts data in a table. Let's break it down:
* emp_id: This represents a column in a table named "person" that stores employee IDs.
* SELECT emp_id: This part of the command tells MySQL to retrieve the values from the "emp_id" column.
* FROM person: This specifies the table from which we're getting the data – the "person" table.
* ORDER BY emp_id DESC: This is the crucial part. It instructs MySQL to arrange the retrieved "emp_id" values in descending order (from highest to lowest).

Now, looking at the given set of emp_id values {9, 7, 6, 4, 3, 1, 2}, if we arrange them in descending order, we get:
{9, 7, 6, 4, 3, 2, 1}

Therefore, the correct answer is Option B: {1, 2, 3, 4, 6, 7, 9}.
This option represents the "emp_id" values sorted in descending order as specified by the MySQL command.

This Question Belongs to MySQL >> MySQL Miscellaneous

Join The Discussion

Related Questions on MySQL Miscellaneous