Results for “SQL”
Small, practical examples. Search by task or narrow things down below.
Convert text without raising a conversion error
Return NULL when a numeric conversion fails.
TRY_CONVERT✓ Tested
Convert Unix time to a timestamp
Interpret a seconds-since-epoch value as UTC.
unixepoch✓ Tested
Copy selected rows into another table
Postgres: INSERT SELECT performs a set-based copy with an explicit destination column list.
Postgres✓ Tested
Count day boundaries between dates
Compare date values with DATEDIFF.
DATEDIFF✓ Tested
Count distinct values within a result
Postgres: COUNT DISTINCT counts distinct non-null values.
Postgres✓ Tested
Count rows per category
Aggregate rows sharing the same category.
GROUP BY✓ Tested
Count rows satisfying separate conditions
Postgres: SUM over CASE expressions calculates several conditional counts in one scan.
Postgres✓ Tested
Count the rows in a table
Postgres: COUNT(*) includes every row, including rows with NULL columns.
Postgres✓ Tested
Create a STRICT table
Require values compatible with declared column types.
STRICT✓ Tested
Create a table and insert its first row
Postgres: Define column types and a primary key, then insert one row using an explicit column list.
Postgres✓ Tested
Create an index for an equality filter
Postgres: A nonunique index can support lookups on a frequently filtered column.
Postgres✓ Tested
Create an index matching filter and ordering columns
Postgres: Place the equality-filter column before the ordering column in this composite index.
Postgres✓ Tested