Learn SQL UNION and UNION ALL to stack results from two queries into one list. Syntax, worked examples with output, duplicates vs speed, and common mistakes.
Tag: Learn SQL
SQL Reference: Quick Guide to All SQL Commands and Syntax
SQL reference and cheat sheet: syntax and descriptions for every major SQL command, clause, operator and function, each linked to its full tutorial chapter.
SQL Window Functions: ROW_NUMBER, RANK, LAG and Running Totals
SQL window functions tutorial: OVER and PARTITION BY, ROW_NUMBER, RANK and DENSE_RANK, running totals with SUM OVER, LAG and LEAD, and top-N per group.
SQL Subqueries: Nested Queries in WHERE, FROM and SELECT
SQL subqueries tutorial: nest a query inside WHERE, FROM or SELECT, scalar vs multi-row subqueries, correlated subqueries, subquery vs JOIN, and examples.
SQL EXISTS Operator: Test Whether a Subquery Returns Rows
SQL EXISTS tutorial: check if a correlated subquery returns any rows, NOT EXISTS for missing matches, EXISTS vs IN vs JOIN, NULL safety, and worked examples.
SQL HAVING Clause: Filter Groups After GROUP BY (Examples)
SQL HAVING clause tutorial: filter aggregated groups with COUNT, SUM and AVG conditions, HAVING vs WHERE, using both together, and examples with output.
SQL GROUP BY Clause: Group Rows and Aggregate Data (Examples)
SQL GROUP BY tutorial: group rows by one or more columns, combine with COUNT, SUM, AVG, MIN and MAX, fix the non-aggregated column error, examples.
SQL FULL JOIN: Combine All Rows from Both Tables (Examples)
SQL FULL JOIN tutorial: return all rows from both tables, NULL where no match, find mismatches on either side, and emulate FULL JOIN in MySQL and SQLite.
SQL RIGHT JOIN: Keep All Rows from the Right Table (Examples)
SQL RIGHT JOIN tutorial: return every row from the right table with matching left rows or NULL, RIGHT JOIN vs LEFT JOIN, find orphan records, and examples.
SQL Joins Explained: INNER, LEFT, RIGHT and FULL JOIN Basics
SQL joins explained: how JOIN combines rows from two tables on a key, the four join types compared on one sample dataset, ON vs WHERE, and which join to use.








