FIND YOUR NEXT FEW LINES

Results for “SQL Server”

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

502 snippets foundClear filters
PostgresDates & series

Generate a sequence of numbers

Create rows without a stored table.

generate_series✓ Tested
PostgresRelationships & missing data

Generate every combination of two sets

Postgres: CROSS JOIN creates one result per possible pair, so the output size is the product of the input sizes.

Postgres✓ Tested
SQLiteQueries & text

Generate numbers with a recursive CTE

Build a bounded sequence using SQL recursion.

recursive CTE✓ Tested
PostgresRows & writes

Get the latest row in each group

Select one ordered row per key with DISTINCT ON.

DISTINCT ON✓ Tested
PostgresGetting Started

Give a result column a readable name

Postgres: Use AS to label a computed result column.

Postgres✓ Tested
PostgresReporting & grouped calculations

Group by more than one field

Postgres: Each distinct combination of grouping fields produces its own row.

Postgres✓ Tested
PostgresSubqueries & ranked selection

Include every row tied for the highest score

Postgres: Compare with MAX rather than limiting to an arbitrary number of rows.

Postgres✓ Tested
PostgresSubqueries & ranked selection

Include missing values in a not-equal filter

Postgres: Ordinary inequality does not include NULL; explicitly include it when that is the intended rule.

Postgres✓ Tested
PostgresRelationships & missing data

Include zero counts for missing relationships

Postgres: Count the non-null child key after a left join so a missing relationship produces zero.

Postgres✓ Tested
PostgresBulk changes & set operations

Increment a stored value in the database

Postgres: An in-database arithmetic update avoids a separate application read-modify-write step.

Postgres✓ Tested
SQLChange & combine data

Insert a row with named columns

Add a record without relying on implicit column order.

INSERT✓ Tested
PostgresBulk changes & set operations

Insert only keys absent from a destination

Postgres: NOT EXISTS supports a set-based missing-row insert in a single-writer example.

Postgres✓ Tested