Use Bayesian average in SQL Server with practical examples, clear checks, and the limits you need before changing your database.
Finding the Most Frequent Value per Group in T-SQL
Find the most frequent value in each group, choose a tie policy, and compare categorical modes with averages and numeric percentiles.
The WINDOW Clause: Name a Window Once and Reuse It
Use the WINDOW clause to reuse partition and order rules, extend named windows with frames, and keep SQL Server calculations consistent.
Merging Overlapping Date Ranges Into Continuous Periods
Use running end dates when merging overlapping ranges, choose boundary rules, and return continuous periods without losing nested intervals.
MERGE Statement Quiz: What If Two Source Rows Match One Target?
This MERGE Statement Quiz asks what happens when two source rows match one target row. The answer is error 8672, and the whole statement fails. A tested script shows the error, the fix with ROW_NUMBER and the same change written as UPDATE plus INSERT.
Ranking Functions Quiz: ROW_NUMBER, RANK or DENSE_RANK?
This Ranking Functions Quiz uses two tied scores to ask what number the next student gets from ROW_NUMBER, RANK and DENSE_RANK. The answer is 3, 3 and 2. A tested script proves it and replaces a cursor loop with one query.
SQL SERVER – Solution to Puzzle – Simulate LEAD() and LAG() without Using SQL Server 2012 Analytic Function
Readers found five ways to simulate LEAD() and LAG() without the SQL Server 2012 analytic functions. This post shows each solution with its author, runs all five on SQL Server 2025 and compares the rows with the real functions. Four return the same ten rows and one adds a rule of its own.







