PERCENTILE_DISC selects from the supplied observations. Preserve duplicates and distinguish an observed threshold from an interpolated value.
DATEADD Nanoseconds: Round to datetime2 Ticks
DATEADD nanoseconds do not provide single-nanosecond storage. Test rounding thresholds with an explicit datetime2(7) input.
REGEXP_MATCHES: Read Matches and Capture Groups
REGEXP_MATCHES returns full matches and captured groups. Read group values and positions, preserve duplicate letters, and check a no-match input.
ISO Week Numbers vs DATEPART(week): Grouping Sales by Week
Group sales by ISO week and ISO year, compare DATEPART week behavior, and avoid New Year errors caused by session settings.
SUM DISTINCT: Equal Amounts Are Not Duplicate Rows
SUM DISTINCT totals different amounts without checking order identity. I’d establish the row grain first. Compare equal-priced orders, repeated copies and missing amounts.
Modulo: Negative Values Keep the Dividend Sign
Modulo can return a negative remainder for a negative dividend. A second expression normalizes a positive-divisor bucket while keeping the original input and remainder visible.
Calculating Age From a Date of Birth Correctly in T-SQL
Use an explicit anniversary rule for calculating age in T-SQL, including February 29, years-months-days output and birthday lookups.







