Tag archive
Commands grouped around the same concept, pattern, or recurring problem.
Remove rows from one table when a matching row exists in another table using a subquery.
Reference the outer query's current row inside a subquery to compute a per-row comparison value.
Embed a `SELECT` inside another query to filter, compute, or supply values that depend on aggregated or derived data.
Use `LATERAL` (or `CROSS APPLY` on SQL Server) to let a subquery reference columns from the preceding table in the `FROM` clause.
Use a correlated subquery inside `EXISTS` to include rows only when related rows are found in another table.
Use a subquery in the `WHERE` clause of an `UPDATE` to restrict which rows are modified based on data from another table.
Wrap a `SELECT` in the `FROM` clause to create a temporary result set you can filter or join against as if it were a real table.
Filter `NULL` values out of the right side before using `NOT IN`, or the predicate can exclude everything.