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 – Legal CASE Defaults and Row Dependent Values
A CASE Expression can appear in a default, but cannot reference another row column there. My earlier blanket prohibition was incorrect.
Conditional Aggregation: Several Counts in One Pass With CASE
Use conditional aggregation for several ticket counts, avoid COUNT with ELSE zero, and calculate percentages with an explicit denominator.
SQL Puzzle – Unsolved CASE Expression
This Unsolved CASE puzzle asks you to predict its result before execution. The preceding bitwise challenge drew more than 125 responses.
ORDER BY a Parameter in SQL Server: CASE, Types and Plans
To ORDER BY a parameter in SQL Server, write one CASE expression for each column and direction. This post builds the procedure, shows the type conversion and DISTINCT errors that trip people up, measures the cost of the sort that CASE forces, and compares OPTION (RECOMPILE) and dynamic SQL.
IIF in SQL Server: IF THEN Logic Compared With CASE
IIF in SQL Server is a short way to write IF THEN logic with two outcomes. This post compares it with CASE in a small juice shop table, shows that both produce the same plan, and covers NULL, data types and the WHERE clause.
Names That Differ Only by Case: Finding Them With COLLATE
A case-insensitive target can turn two rows into one. This walk-through finds the colliding names first, including the ones with trailing spaces.







