MySQL ORDER BY
- Is there any error in the following query?
SELECT emp_id, title, start_date, fname, fed_id
FROM Employee
ORDER BY 3, 4;
-
View Hint View Answer Discuss in Forum
NA
Correct Option: A
“ORDER BY” clause can be used with Place holders. Here “3” represent column “title” and “4” represent “fed_id”. Therefore it look like “ORDER BY title, fed_id”.
- Keyword “ASC” and “DESC” cannot be used without which clause in Mysql?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
“ASC” or “DESC” are used to sort the result set in ascending or descending order therefore they cannot be used without “ORDER BY” clause.
- What is the significance of “ORDER BY emp_id DESC” in the given query?
SELECT id, First_name, Last_name
FROM Student
ORDER BY id DESC;
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
Keyword “DESC” will sort the data in descending order.
- What is the significance of “ORDER BY emp_id ASC” in the given query?
SELECT id, First_name, Last_name
FROM Student
ORDER BY id ASC;
-
View Hint View Answer Discuss in Forum
NA
Correct Option: B
Keyword “ASC” will sort the data in ascending order.
- If id contain the following set {9, 7, 6, 4, 3, 1, 2}, what will be the output on execution of the given query?
SELECT id
FROM Student
ORDER BY id DESC;
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
“DESC” clause sort the id in the descending order.