FIND YOUR NEXT FEW LINES

The snippet library.

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

25 snippets foundClear filters
SQL ServerGetting Started

Join related rows from two tables

SQL Server: Match a category key to its display label with an explicit join condition.

SQL Server✓ Tested
SQL ServerGetting Started

Keep rows matching a condition

SQL Server: Use WHERE to select rows with a particular category.

SQL Server✓ Tested
SQL ServerGetting Started

Match a text prefix

SQL Server: Use a percent wildcard after a known prefix.

SQL Server✓ Tested
SQL ServerGetting Started

Match one value from a short list

SQL Server: Use IN for a set of allowed values.

SQL Server✓ Tested
SQL ServerGetting Started

Read named columns from a table

SQL Server: Choose the columns needed and request a deterministic row order.

SQL Server✓ Tested
SQL ServerGetting Started

Read the smallest and largest values

SQL Server: Use MIN and MAX without sorting and fetching every row.

SQL Server✓ Tested
SQL ServerGetting Started

Remove duplicate result values

SQL Server: Use DISTINCT when repeated category values are not useful.

SQL Server✓ Tested
SQL ServerGetting Started

Require two filtering conditions

SQL Server: Combine category and quantity conditions with AND.

SQL Server✓ Tested
SQL ServerGetting Started

Run a first SELECT query

SQL Server: Return a literal value without creating a table.

SQL Server✓ Tested
SQL ServerGetting Started

Select values in an inclusive range

SQL Server: BETWEEN includes both endpoints of the range.

SQL Server✓ Tested
SQL ServerGetting Started

Sort the highest quantities first

SQL Server: Specify descending order and a stable tie breaker.

SQL Server✓ Tested
SQL ServerGetting Started

Turn a condition into a result label

SQL Server: Use CASE to describe stock availability for each row.

SQL Server✓ Tested