FIND YOUR NEXT FEW LINES

Results for “SQL Server”

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

502 snippets foundClear filters
SQL ServerSubqueries & ranked selection

Report duplicate business values and their frequency

SQL Server: Group by a candidate business key and retain only groups with multiple rows.

SQL Server✓ Tested
SQL ServerConstraints & defaults

Require a value with NOT NULL

SQL Server: Declare required fields at the database boundary, not only in application validation.

SQL Server✓ Tested
SQL ServerGetting Started

Require two filtering conditions

SQL Server: Combine category and quantity conditions with AND.

SQL Server✓ Tested
SQL ServerSubqueries & ranked selection

Return all rows tied for the maximum in a group

SQL Server: An equality comparison with a grouped maximum retains ties rather than choosing one arbitrary row.

SQL Server✓ Tested
SQL ServerReporting & grouped calculations

Return zero for a sum over no rows

SQL Server: SUM produces NULL for an empty input; COALESCE supplies the desired reporting default.

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 ServerText cleanup & matching

Search for a literal LIKE wildcard

SQL Server: Declare an escape character so a percent sign in the pattern is literal.

SQL Server✓ Tested
SQL ServerWindow analytics

Select the top row in each group with a tie-breaker

SQL Server: Filter an outer query on ROW_NUMBER because window functions are not evaluated in WHERE.

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 ServerWindow analytics

Show a group total beside each detail row

SQL Server: A partitioned aggregate preserves detail rows instead of collapsing them with GROUP BY.

SQL Server✓ Tested
SQL ServerSubqueries & ranked selection

Sort preferred rows ahead of other rows

SQL Server: A CASE ordering key expresses business priority before a stable secondary sort.

SQL Server✓ Tested
SQL ServerGetting Started

Sort the highest quantities first

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

SQL Server✓ Tested