SQL Essentials
SQL is essential for database querying.
Basic Queries
SELECT columns FROM table WHERE conditions GROUP BY column HAVING aggregate_conditions.
ORDER BY column (ASC/DESC), LIMIT n. DISTINCT for unique values.
Joins
INNER JOIN: matching rows from both. LEFT JOIN: all from left, matching right.
RIGHT JOIN, FULL OUTER JOIN. Multiple joins: (table1 JOIN table2 ON ...) JOIN table3.
Aggregations
COUNT, SUM, AVG, MIN, MAX. GROUP BY creates groups. HAVING filters groups.
Window functions: ROW_NUMBER(), RANK(), SUM() OVER (PARTITION BY).
Key Takeaways
- SELECT-FROM-WHERE is core query structure
- JOINs combine tables
- Window functions enable complex analytics