MySQL ORDER BY


  1. Is there any error in the following query?
    SELECT emp_id, title, start_date, fname, fed_id
    FROM Employee
    ORDER BY 3, 4;











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


  1. Keyword “ASC” and “DESC” cannot be used without which clause in Mysql?











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



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











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    Keyword “DESC” will sort the data in descending order.


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











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: B

    Keyword “ASC” will sort the data in ascending order.



  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 DESC;











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    “DESC” clause sort the id in the descending order.