FIND YOUR NEXT FEW LINES

Results for “SQL”

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

500 snippets foundClear filters
PostgresGetting Started

Sort the highest quantities first

Postgres: Specify descending order and a stable tie breaker.

Postgres✓ Tested
SQL ServerDates & text

Split delimited text with positions

Retain original order with STRING_SPLIT ordinals.

STRING_SPLIT✓ Tested
SQL ServerSelect & page

Substitute a value for NULL

Use SQL Server’s ISNULL expression.

ISNULL✓ Tested
PostgresWindow analytics

Sum a row and its immediate predecessor

Postgres: A ROWS frame counts physical ordered rows rather than all peers with the same sort value.

Postgres✓ Tested
SQLExpressions & aggregates

Sum values per category

Calculate a grouped total.

SUM✓ Tested
SQLChange & combine data

Test missing values with IS NULL

Find rows where an optional value is absent.

IS NULL✓ Tested
PostgresText cleanup & matching

Treat an empty trimmed value as missing

Postgres: NULLIF converts an empty string to NULL before a fallback is applied.

Postgres✓ Tested
PostgresGetting Started

Turn a condition into a result label

Postgres: Use CASE to describe stock availability for each row.

Postgres✓ Tested
SQL ServerJSON & results

Turn JSON into typed rows

Project JSON array items into SQL columns.

OPENJSON✓ Tested
PostgresReporting & grouped calculations

Turn known group values into columns

Postgres: Conditional aggregation gives a portable pivot when the category set is known.

Postgres✓ Tested
PostgresSchema design & transactions

Undo a multi-row transfer atomically

Postgres: The first transaction commits the fixtures. Rolling back the second transaction restores both sides of the attempted transfer.

Postgres✓ Tested
PostgresSchema design & transactions

Undo only the work after a savepoint

Postgres: After committing the fixtures, roll back a trial change while keeping earlier work in the second transaction.

Postgres✓ Tested