MySQL ORDER BY


  1. 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;











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    “ASC” clause sort the emp_id in the ascending order.


  1. Find odd one out?











  1. 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.



  1. 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);











  1. 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.


  1. 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);











  1. 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.