Order | Clause | Description |
1 | FROM | Choose your tables from where to get the data |
2 | JOIN | Join matching data between tables |
3 | WHERE | Filters the data |
4 | GROUP BY | Aggregates the data |
5 | HAVING | Filters the aggregated data |
6 | SELECT | Returns the selected columns you choose |
7 | ORDER BY | Sorts the final data |
This is meant to be a quick reference. One could write a book about each item in detail.
When tuning your SQL, start from the top and go to the bottom. Utilize built in execution plan feature to identify costly operations.
