Which one of the following sorts of rows in SQL

    Which one of the following sorts of rows in SQL

    Table of Contents

    The  ORDER BY Clause is used to sort the result set in ascending order and descending order. If you want to sort the result set either in ascending or descending order then we need to use SQL ORDER BY Clause.

    The ORDER BY keyword sorts the records in ascending order by default.

    Syntax:

    Select  COLUMN1,COLUMN2,COLUM3  from  table_name order by (asc|desc)

    or

    select * from table name order by by (asc|desc)

    Expressions: The columns or calculations that we want to retrieve.

    ASC: If you want to sort the data in ascending order of the expression then you need to use ASC.

    DESC: If you want to sort data in descending order by expression then you need to the DESC keyword.

    Which one of the following sorts of rows in SQL

    Let’s do this step by step

    1. First we want to create a table for using ORDER BY Clause in the SQL Server.

    2. We want to insert the value from the table.

    3. Select the table.

    4. Now we are using order by 1  ASC.1 means the first column. The first column is already in the ascending order value .sql because the default result-set is that’s why data is changing the select query.

    5. Now we are using order by 2 ASC which means it will change the second column in the ascending order from the table.

    6. Now we are using order by 1  DESC. It will change the first column from descending to ascending order.

    7. Now we are using order by  First_name  DESC. It will change the second column from descending to ascending order.

    8. Now we using the where condition in the select query and also we have added both asc and desc in the SQL query.

    Conclusion

    I hope you found this article about Which one of the following sorts of rows in SQL is helpful.

    Now I’d like to hear what you have to say:

    What topic i would like to cover in my future

    Let me know by leaving a comment below.

    Sign up now to receive our monthly newsletter.
    We promise to not use your email for spam!

    Leave a comment on this post

    Latest Posts