Basic SQL Functions – Part 4: ORDER BY Statement

By: Tyler Dougherty

June 3, 2020

Similar to the GROUP BY clause, the ORDER BY clause also determines how the data is displayed in the view and not so much what the view is displaying. The ORDER BY clause controls the order in which records appear in a view. The order can be determined by the numerical magnitude if it is a numerical data type, or the alphabetical order if it is a char data type.

There is also a functionality to ORDER BY that allows the user to determine if they want the records to show in ascending order or descending order. By default, if we say ORDER BY total_amount, this will order the view by the total amount spent in ascending order. If we would like to specify that we want the total amount spent to be ordered by descending order we would specify that in the statement, ORDER BY total_amount desc, tacking on desc at the end of the order by will accomplish this.

The ORDER BY clause is placed after the GROUP BY clause.

Click here for Part 5: JOINS

Subscribe to QueBIT Notifications

Can’t find what you’re looking for? →

    Contact Help Desk

    This form collects your contact information so that we can correspond with you. For more information on how we are committed to protecting and respecting your privacy, please review our Privacy Policy.

    I consent to QueBIT collecting my contact information.