MySQL Questions and Answers – The order by Clauses – 1

This set of MySQL Multiple Choice Questions & Answers (MCQs) focuses on “The order by Clauses – 1”.

1. Is “GROUP BY” clause is similar to “ORDER BY” clause?
a) Yes
b) No
c) Depends
d) None of the mentioned
View Answer

Answer: b
Explanation: “ORDER BY” clause is used for sorting while “GROUP BY” clause is used for aggregation of fields.

2. What is the meaning of “ORDER BY” clause in Mysql?
a) Sorting your result set using column data
b) Aggregation of fields
c) Sorting your result set using row data
d) None of the mentioned
View Answer

Answer: a
Explanation: None.

3. What is the significance of “ORDER BY” in the following MySQL statement?

advertisement
advertisement
SELECT emp_id, fname, lname
FROM person
ORDER BY emp_id;

a) Data of emp_id will be sorted
b) Data of emp_id will be sorted in descending order
c) Data of emp_id will be sorted in ascending order
d) All of the mentioned
View Answer

Answer: a
Explanation: Sorting in ascending or descending order depends on keyword “DESC” and “ASC”.

4. What will be the order of sorting in the following MySQL statement?

SELECT emp_id, emp_name
FROM person
ORDER BY emp_id, emp_name;

a) Sorting {emp_id, emp_name}
b) Sorting {emp_name, emp_id}
c) Sorting (emp_id} but not emp_name
d) None of the mentioned
View Answer

Answer: a
Explanation: In the query, first “emp_id” will be sorted then emp_name with respect to emp_id.
advertisement

5. 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 statement?

advertisement
SELECT emp_id
FROM person
ORDER BY emp_id;

a) {1, 2, 3, 4, 6, 7, 9}
b) {2, 1, 4, 3, 7, 9, 6}
c) {9, 7, 6, 4, 3, 1, 2}
d) None of the mentioned
View Answer

Answer: a
Explanation: “ORDER BY” clause sort the emp_id in the result set.

6. 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
View Answer

Answer: a
Explanation: “ORDER BY” clause sort the emp_id in the result set.

7. If emp_id contain the following set {1, 2, 2, 3, 3, 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, 2, 2, 3, 3}
b) {1, 2, 3, 3, 2, 1}
c) {2, 2, 1, 1, 3, 3}
d) None of the mentioned
View Answer

Answer: a
Explanation: “ORDER BY” clause sort the emp_id in the result set.

8. If emp_id contain the following set {-1, -2, 2, 3, -3, 1}, what will be the output on execution of the following MySQL statement?

SELECT emp_id
FROM person
ORDER BY emp_id;

a) {-3, -2, -1, 1, 2, 3}
b) {-1, 1, -2, 2, -3, 3}
c) {1, 2, 3, -1, -2, -3}
d) None of the mentioned
View Answer

Answer: a
Explanation: “ORDER BY” clause sort the emp_id in the result set.

9. Which keyword is used for sorting the data in descending order in Mysql?
a) DESC
b) ASC
c) ALTER
d) MODIFY
View Answer

Answer: a
Explanation: None.

10. Which keyword is used for sorting the data in ascending order in Mysql?
a) DESC
b) ASC
c) ALTER
d) MODIFY
View Answer

Answer: b
Explanation: None.

Sanfoundry Global Education & Learning Series – MySQL Database.

To practice all areas of MySQL Database, here is complete set of 1000+ Multiple Choice Questions and Answers.

If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.