Omar Hosney
LinkedIn

PostgreSQL SQL Syntax Cheatsheet ๐Ÿ“„

๐Ÿ” Schema & Meta

๐Ÿ“ Basic Data Operations

๐Ÿค Standard Joins

๐Ÿ”„ Special Join

๐Ÿ–ผ๏ธ Joins Visualized

INNER JOIN
LEFT JOIN
RIGHT JOIN
FULL JOIN

๐Ÿงช Data Types

๐Ÿ—๏ธ Table Management

๐Ÿ”Ž Query Clauses

๐Ÿ”ข Aggregate Functions

โž— Arithmetic & Rounding

โฐ Date & Time Functions

๐Ÿ” Permissions

๐Ÿ“ค Exporting Data from PostgreSQL

๐Ÿ“ฅ Importing Data into PostgreSQL

๐Ÿ—‚๏ธ Working with JSON Fields

๐Ÿ”ญ Creating & Using Views

๐Ÿงฉ Building Nested SQL Queries

๐Ÿ”‘ Essential SQL Keywords I

๐Ÿ”Ž WHERE vs HAVING

Note: In PostgreSQL, WHERE cannot use avg_salary because aliases are not available until after the SELECT clause is processed. HAVING can use avg_salary because it is evaluated after aggregation and SELECT.

๐Ÿงฉ Essential SQL Keywords II

๐Ÿ“Š SQL Order of Execution

FROM / JOIN WHERE GROUP BY HAVING SELECT DISTINCT ORDER BY LIMIT / OFFSET
Order of execution in SQL:
FROM/JOIN โ†’ WHERE โ†’ GROUP BY โ†’ HAVING โ†’ SELECT โ†’ DISTINCT โ†’ ORDER BY โ†’ LIMIT/OFFSET