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
A rotary egg beater rests between separate mixing bowls and a jug of already beaten mixture

CTE Referenced Twice: Why the Query Runs It Twice

April 16, 2012
Pinal Dave
SQL Performance
CTE, Execution Plan, SQL Group By, Temp Table

Writing a CTE name two times can mean doing the work two times. Two small demos show when a temp table helps and when it only adds cost.

Read More
Repeated bundles of loose bed slats sit beside the compact assembled bed frame

Triangular Joins: The Hidden Row Explosion in Self-Joins

April 6, 2012
Pinal Dave
SQL Tips and Tricks
SQL Function, SQL Group By, SQL Joins, Temp Table

A small grouped result can hide a huge pile of row pairs. Here is how to count them and what to do instead.

Read More
Loose wooden dowels and tied bundles rest on a slate tray beside four bundles inside an open wooden crate.

Aggregate Before the Join: Shrinking Rows Early With GROUP BY

May 4, 2010
Pinal Dave
SQL Performance
SQL Group By, SQL Joins, SQL Performance

Aggregate before the join only when the grouping preserves the required customer result. This private lab checks NULLs, missing matches, duplicate dimensions, complete outputs, actual plans, and reads.

Read More
A round pizza cut from two slightly different starting points, leaving one narrow sliver between the cuts.

ISO Week Numbers vs DATEPART(week): Grouping Sales by Week

August 25, 2009
Pinal Dave
SQL Tips and Tricks
SQL DateTime, SQL Function, SQL Group By, SQL Server

Group sales by ISO week and ISO year, compare DATEPART week behavior, and avoid New Year errors caused by session settings.

Read More
A hand fits a brass hinge pin while matching spare pins lie on the bench.

Finding Duplicates Before Adding a Unique Constraint

July 27, 2009
Pinal Dave
SQL Tips and Tricks
Duplicate Records, Ranking Functions, SQL Constraint and Keys, SQL Group By, SQL NULL

A unique constraint fails on the first duplicate it meets and tells you about only one. Here is how to list them all and clean up safely.

Read More
Pistachios fill six cavities of a wooden mold while two middle cavities remain empty.

Value Histograms: Counting Rows per Range Bucket in T-SQL

February 21, 2009
Pinal Dave
SQL Tips and Tricks
SQL Group By, SQL Scripts, Temp Table

Turn a column of amounts into a clear shape. Three small traps decide whether your bucket counts are true: empty buckets, uneven ranges and BETWEEN.

Read More
A rich painting pairs handmade blue, ochre and sage tiles arranged in horizontal rows and vertical columns.

PIVOT and UNPIVOT: Aggregation, NULLs and Cross-Tab Queries

October 1, 2008
Pinal Dave
SQL Tips and Tricks
PIVOT and UNPIVOT, SQL Group By, SQL Server

PIVOT and UNPIVOT reshape SQL Server data. See a tested example, disappearing NULLs, aggregation and fixed cross-tab columns.

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

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