SQL ORDER BY Statement


Intro

Use the ORDER BY keyword to sort the resulting record set in either ascending or descending order


Sample Data

This is the table we will use as an example:

SELECT * 
FROM ar_invoices
invoice# customer# salesperson# invoice_date invoice_amount amount_paid current_month_interest_charges total_interest_charges
1112019-06-17 10:43:53.727100.001.000.000.00
2222019-05-28 10:43:53.72750.000.005.0010.00
3322019-06-17 10:43:53.72770.000.0010.0020.00
4212019-07-07 10:43:53.72780.000.000.000.00

Syntax


SELECT column1, column2, ...
FROM table_name
ORDER BY column1, column2, ... ASC|DESC
SELECT invoice#, 
       invoice_amount
FROM ar_invoices
ORDER BY invoice_amount DESC
invoice# invoice_amount
1100.00
480.00
370.00
250.00