Data binning turns a column of numbers into a few groups you can count and chart. This post runs four T-SQL methods on the same orders on SQL Server 2025: fixed width, NTILE, CASE ranges and DATE_BUCKET. It shows what each method tells you and one trap with BETWEEN.
SQL SERVER Challenge – Cumulative Total Calculation
Today we will see a very interesting SQL SERVER Challenge about Cumulative Total Calculation. During a recent Comprehensive Database Performance Health Check.
Filtering on a Window Function Without QUALIFY in SQL Server
Filter window results without QUALIFY using CTEs and derived tables, compare TOP WITH TIES, and preserve partition and tie rules.
Quartiles With PERCENTILE_CONT and NTILE
Compare quartiles from PERCENTILE_CONT with NTILE row buckets, calculate interquartile range, and flag candidates beyond 1.5 IQR.
Top N Plus Others: Grouping the Rest Into One Row
Create top N plus others summaries with deterministic category ranking, one remainder total, stable labels, and explicit display ordering.
Rewriting Correlated Subqueries as Window Functions
Replace correlated subqueries with windowed counts, dates, and running totals, preserve detail rows, and keep useful EXISTS filters.
Twenty Practice Queries on One Small Schema
Work through twenty practice queries on one small sales schema, with expected results for filters, joins, totals, windows, and gaps.







