Cite
- https://towardsdatascience.com/take-your-sql-from-good-to-great-part-1-3ae61539e92a
- https://towardsdatascience.com/take-your-sql-from-good-to-great-part-2-cb03b1b7981b
- https://towardsdatascience.com/take-your-sql-from-good-to-great-part-3-687d797d1ede
- https://towardsdatascience.com/take-your-sql-from-good-to-great-part-4-99a55fd0e7ff
- https://towardsdatascience.com/take-your-sql-from-good-to-great-part-5-7c996dbcc527
Common Table Expressions (CTEs)
Temporary tables that are available in a single query
WITH cte_name AS
(SELECT ... FROM ...)
SELECT * FROM cte_name- Subquery vs CTE
- Easier to understand
- Faster iteration
- Validations
Date and Time
- Construct
- Extract
- Add/Subtraction
- Truncate
- Parse
- Format
- Generate
Execution Order
- FROM, JOIN
- WHERE
- GROUP BY
- HAVING
- SELECT
- ORDER BY
- LIMIT
Join

- INNER JOIN
- X and Y
- Exclude NULL
- Range JOIN
- Joining by inequalities, e.g. date ranges
- Lateral JOIN
- Access columns after FROM
- A FOR EACH operator
Window Functions
FUNC(xxx) OVER (PARTITION BY xxx ORDER BY xxx FUNC)