In the below SQL query, the query execution happens in the following order:
- FROM and JOINs
- WHERE
- GROUP BY
- HAVING
- SELECT
- DISINCT
- ORDER BY
- LIMIT or OFFSET
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;
If you want to learn SQL and writing SQL queries, I recommend this SQL Training course by Intellipaat that provides Instructor-led training, certification, and also job assistance.