ORDER OF OPERATIONS SQL code example
Example 1: sql order of operations
SELECT DISTINCT column, AGG_FUNC(column_or_expression), …
FROM mytable
JOIN another_table
ON mytable.column = another_table.column
WHERE constraint_expression
GROUP BY column
HAVING constraint_expression
ORDER BY column ASC/DESC
LIMIT count OFFSET COUNT;
Example 2: sql order by
Used to sort the result data in ascending (default) or descending order
through the use of ASC or DESC keywords.
Example: Returns countries in alphabetical order.
SELECT * FROM countries
ORDER BY name;