Examveda

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

A. {1, 1, 1, 2, 3, 4}

B. {1, 2, 3, 4, 1, 1}

C. {1, 1, 2, 3, 4, 1}

D. None of the mentioned

Answer: Option A

Solution (By Examveda Team)

This question is about how MySQL orders data. We have a set of employee IDs (emp_id) {1, 2, 3, 4, 1, 1} in a table called person.
The SQL statement SELECT emp_id FROM person ORDER BY emp_id; tells MySQL to:
1. Select the employee IDs (emp_id)
2. From the table called person
3. Order them by the employee ID, from smallest to largest.
Therefore, the correct output is Option A: {1, 1, 1, 2, 3, 4} because the statement sorts the IDs in ascending order.
The duplicates (1, 1, 1) are not removed by the ORDER BY clause, they just appear in the order based on their numerical value.

This Question Belongs to MySQL >> MySQL Miscellaneous

Join The Discussion

Related Questions on MySQL Miscellaneous