MySQL ORDER BY
- 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 ASC;
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
“ASC” clause sort the emp_id in the ascending order.
- Find odd one out?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
“ORDER BY”, “DESC”, “ASC” are related to sorting whereas “GROUP BY” is not related to sorting.
- Is there any error in the following query?
SELECT emp_id, title, start_date, First_name, fed_id
FROM Employee
ORDER BY RIGHT (fed_id, 3);
-
View Hint View Answer Discuss in Forum
NA
Correct Option: A
“ORDER BY” clause can be used with expression such as fed_id, which is a social security no like 111, 111, 111 therefore we sort it taking only three digits from right.
- Is there any error in the following query?
SELECT emp_id, title, start_date, fname, fed_id
FROM Employee
ORDER BY LEFT (fed_id, 5);
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
“ORDER BY” clause can be used with expression such as fed_id which is a social security no like 111, 111, 111 therefore we sort it taking only 5 digits from left.