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
Birds on three telegraph wires at dusk, each wire mostly one kind of bird with a few others mixed in.

Finding the Most Frequent Value per Group in T-SQL

October 28, 2013
Pinal Dave
SQL Tips and Tricks
Ranking Functions, SQL Group By, SQL Scripts, SQL Server

Find the most frequent value in each group, choose a tie policy, and compare categorical modes with averages and numeric percentiles.

Read More
A child's hand printing the same red leaf shape in a row on brown paper with one carved potato stamp.

The WINDOW Clause: Name a Window Once and Reuse It

November 29, 2012
Pinal Dave
SQL Tips and Tricks
Ranking Functions, SQL Function, SQL Server, SQL Server 2022

Use the WINDOW clause to reuse partition and order rules, extend named windows with frames, and keep SQL Server calculations consistent.

Read More
A roofer laying overlapping wooden shingles: one long continuous run, a bare gap, then a short second run.

Merging Overlapping Date Ranges Into Continuous Periods

October 22, 2012
Pinal Dave
SQL Tips and Tricks
Ranking Functions, SQL DateTime, SQL Scripts, SQL Server

Use running end dates when merging overlapping ranges, choose boundary rules, and return continuous periods without losing nested intervals.

Read More
A smooth band of mist following the shape of a jagged mountain ridge

Moving Averages in T-SQL

September 18, 2011
Pinal Dave
SQL Tips and Tricks
Ranking Functions, SQL Function, SQL Scripts, SQL Server

Moving averages in T-SQL use ROWS BETWEEN for rolling windows, but date gaps and duplicate dates decide what the result actually means.

Read More
SQL SERVER - Ranking Functions - RANK( ), DENSE_RANK( ), and ROW_NUMBER( ) - Day 12 of 35

SQL SERVER – Ranking Functions – RANK( ), DENSE_RANK( ), and ROW_NUMBER( ) – Day 12 of 35

August 12, 2011
Pinal Dave
SQL Tips and Tricks
Joes 2 Pros, Ranking Functions, SQL Scripts, SQL Server

RANK( ), DENSE_RANK( ), and ROW_NUMBER( ) return the same results until your data has a tie. Day 12 shows how each ranking function handles tied values.

Read More
Socks sorted into matched pairs on a quilt, a small pile of odd socks set apart, a hand holding up one sock.

Solving SQL Puzzles With Set-Based Thinking

March 20, 2008
Pinal Dave
SQL Puzzle
Ranking Functions, SQL Joins, SQL Scripts, SQL Server

Set-based thinking solves three SQL puzzles with grouping, anti-joins, and windows, then turns each solution into a repeatable query habit.

Read More
Sql server query results window.

SQL SERVER – 2005 – Sample Example of RANKING Functions – ROW_NUMBER, RANK, DENSE_RANK, NTILE

October 9, 2007
Pinal Dave
SQL Tips and Tricks
Ranking Functions, SQL Function, SQL Scripts

SQL Server 2005 has four ranking functions: ROW_NUMBER, RANK, DENSE_RANK and NTILE. I explain what each returns and show a sample example of all four.

Read More
Previous 1 2 3 4
  • Books
  • Testimonials
  • Privacy Policy

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