FIND YOUR NEXT FEW LINES

Results for “SQL”

Small, practical examples. Search by task or narrow things down below.

500 snippets foundClear filters
SQL ServerSelect & page

Convert text without raising a conversion error

Return NULL when a numeric conversion fails.

TRY_CONVERT✓ Tested
SQLiteDates & time

Convert Unix time to a timestamp

Interpret a seconds-since-epoch value as UTC.

unixepoch✓ Tested
PostgresBulk changes & set operations

Copy selected rows into another table

Postgres: INSERT SELECT performs a set-based copy with an explicit destination column list.

Postgres✓ Tested
SQL ServerDates & text

Count day boundaries between dates

Compare date values with DATEDIFF.

DATEDIFF✓ Tested
PostgresReporting & grouped calculations

Count distinct values within a result

Postgres: COUNT DISTINCT counts distinct non-null values.

Postgres✓ Tested
SQLExpressions & aggregates

Count rows per category

Aggregate rows sharing the same category.

GROUP BY✓ Tested
PostgresReporting & grouped calculations

Count rows satisfying separate conditions

Postgres: SUM over CASE expressions calculates several conditional counts in one scan.

Postgres✓ Tested
PostgresGetting Started

Count the rows in a table

Postgres: COUNT(*) includes every row, including rows with NULL columns.

Postgres✓ Tested
SQLiteTables & writes

Create a STRICT table

Require values compatible with declared column types.

STRICT✓ Tested
PostgresGetting Started

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
PostgresSchema design & transactions

Create an index for an equality filter

Postgres: A nonunique index can support lookups on a frequently filtered column.

Postgres✓ Tested
PostgresSchema design & transactions

Create an index matching filter and ordering columns

Postgres: Place the equality-filter column before the ordering column in this composite index.

Postgres✓ Tested