Results for “SQL Server”
Small, practical examples. Search by task or narrow things down below.
Filter rows with WHERE
Keep products below a chosen price.
WHERE✓ Tested
Find missing values with IS NULL
Postgres: Use IS NULL rather than equality to test for missing data.
Postgres✓ Tested
Find parents whose every child meets a rule
Postgres: Combine existence with the absence of a violating child to exclude parents with no children.
Postgres✓ Tested
Find parents with at least two child rows
Postgres: Use a correlated count when testing a per-parent threshold.
Postgres✓ Tested
Find records without any related rows
Postgres: NOT EXISTS avoids the NULL pitfalls of NOT IN when the subquery column can be missing.
Postgres✓ Tested
Find rows in the first result but not the second
Postgres: EXCEPT calculates a distinct result-set difference.
Postgres✓ Tested
Find rows shared by two query results
Postgres: INTERSECT compares complete selected rows and removes duplicates.
Postgres✓ Tested
Find rows with a related record
Use EXISTS without duplicating the outer rows.
EXISTS✓ Tested
Find the first day of a month
Round a date to its calendar month boundary.
date✓ Tested
Find the second-highest distinct value
Postgres: Select the maximum below the overall maximum to skip ties at the top.
Postgres✓ Tested
Format a timestamp
Extract a year and month from ISO timestamp text.
strftime✓ Tested
Format a timestamp with to_char
Produce a fixed numeric date string.
to_char✓ Tested