This month's discount Comprehensive Database Performance Health Check · Testimonials
SQLAuthority with Pinal Dave
Home
  • Consulting
    • Health Check
  • Free Videos
  • All Articles
    • AI
    • SQL Performance
    • SQL Tips and Tricks
    • Interview Questions and Answers
    • SQL Puzzle
    • SQL Video
    • SQLAuthority News
    • Personal
  • Books
  • Consulting
Gouache painting: a row of wooden crates of graduated widths along a barn wall, a chute pouring mangoes into the first and widest crate, one crate painted vermilion

Data Binning in T-SQL: Fixed Width, NTILE, CASE, DATE_BUCKET

October 13, 2023
Pinal Dave
SQL Tips and Tricks
Ranking Functions, SQL CASE, SQL DateTime, SQL Group By, SQL Scripts

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.

Read More
CumulativeTotalCalculation

SQL SERVER Challenge – Cumulative Total Calculation

June 16, 2023
Pinal Dave
SQL Interview Questions and Answers
Contest, CTE, Ranking Functions, SQL Scripts, SQL Sub Query

Today we will see a very interesting SQL SERVER Challenge about Cumulative Total Calculation. During a recent Comprehensive Database Performance Health Check.

Read More
A hand pinning a red rosette on the largest marrow in a row already arranged by size on a village show table.

Filtering on a Window Function Without QUALIFY in SQL Server

October 5, 2021
Pinal Dave
SQL Tips and Tricks
CTE, Ranking Functions, SQL Server, SQL Top

Filter window results without QUALIFY using CTEs and derived tables, compare TOP WITH TIES, and preserve partition and tie rules.

Read More
Sixteen pineapples in a row by size, split into four groups by wooden slats, one huge pineapple set apart.

Quartiles With PERCENTILE_CONT and NTILE

January 1, 2021
Pinal Dave
SQL Tips and Tricks
Mathematical Function, Ranking Functions, SQL Function, SQL Server

Compare quartiles from PERCENTILE_CONT with NTILE row buckets, calculate interquartile range, and flag candidates beyond 1.5 IQR.

Read More
A knife block with five large knives, beside one small pot holding all the smaller utensils bunched together.

Top N Plus Others: Grouping the Rest Into One Row

December 3, 2020
Pinal Dave
SQL Tips and Tricks
Ranking Functions, SQL Group By, SQL Scripts, SQL Server, SQL Top

Create top N plus others summaries with deterministic category ranking, one remainder total, stable labels, and explicit display ordering.

Read More
A hand carrying three drinks and a plate on one wooden tray across a cafe terrace, worn gravel paths behind.

Rewriting Correlated Subqueries as Window Functions

October 31, 2020
Pinal Dave
SQL Tips and Tricks
Ranking Functions, SQL Function, SQL Performance, SQL Server, SQL Sub Query

Replace correlated subqueries with windowed counts, dates, and running totals, preserve detail rows, and keep useful EXISTS filters.

Read More
A single lane of hurdles on a running track, each one higher than the last, the tallest one vermilion.

Twenty Practice Queries on One Small Schema

April 3, 2020
Pinal Dave
SQL Tips and Tricks
Ranking Functions, SQL Joins, SQL Server, SQL Training, Starting SQL

Work through twenty practice queries on one small sales schema, with expected results for filters, joins, totals, windows, and gaps.

Read More
1 2 3 4 … 6 Next
  • Books
  • Testimonials
  • Privacy Policy

© 2006 – 2026 All rights reserved. pinal @ SQLAuthority.com