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
Four pale ceramic bowls in two pairs, three empty and the front-right bowl filled with blue pebbles.

IS DISTINCT FROM: Compare Nullable Values Without Sentinel Values

March 17, 2011
Pinal Dave
SQL Tips and Tricks
SQL NULL, SQL Scripts, SQL Server, SQL Server 2022

IS DISTINCT FROM compares nullable values without inventing a sentinel. Test two NULLs, one NULL and changed values, then use the predicate to find transitions that ordinary equality can miss.

Read More
Glass bottles on a windowsill arranged tallest to shortest, one short vermilion bottle out of place in the middle.

Sorting Correctly: Collation and ORDER BY

February 10, 2011
Pinal Dave
SQL Tips and Tricks
SQL Collation, SQL NULL, SQL Order By, SQL Server

Collation and ORDER BY decide case, accent, and text-number order; choose rules explicitly when one report needs different sorting.

Read More
Folded deckchairs taken from a tall stack and opened one by one in a long row along the beach.

Unpivoting Columns Into Rows With CROSS APPLY and VALUES

December 2, 2010
Pinal Dave
SQL Tips and Tricks
PIVOT and UNPIVOT, SQL NULL, SQL Scripts, SQL Server

Use CROSS APPLY and VALUES for unpivoting columns, retain nulls deliberately, preserve labels, and turn paired fields into aligned rows.

Read More
Two trays pair a blue bowl with a cream jug and a blue jug with a cream bowl.

Count Distinct Pairs: Keep the Columns Together

June 27, 2010
Pinal Dave
SQL Tips and Tricks
Developer, SQL Distinct, SQL NULL, SQL Server, SQL Sub Query

Count distinct pairs by keeping their columns together. A small T-SQL example shows why concatenated labels can collide. Choose whether incomplete pairs belong in the count.

Read More
A string of dried chili peppers hung in order from smallest to largest, hands adding one fresh red pepper in place.

Ordered Comma Lists With STRING_AGG and WITHIN GROUP

September 18, 2009
Pinal Dave
SQL Tips and Tricks
SQL Function, SQL NULL, SQL Server, SQL String

Build ordered comma lists with STRING_AGG and WITHIN GROUP, remove duplicates, handle nulls, and avoid fixed-length result limits.

Read More
A hand fits a round-pin charger plug into a red travel adapter on a desk

Oracle to SQL Server: Translating NVL, ROWNUM and Sequences

August 31, 2009
Pinal Dave
SQL Tips and Tricks
Oracle, SQL Migration, SQL NULL, SQL Server

Translate Oracle to SQL Server expressions for NULLs, row limits, dates, sequences and concatenation, and test where they differ.

Read More
Two red ceramic pitchers stand beside a blue pitcher on a sunlit workbench.

SUM DISTINCT: Equal Amounts Are Not Duplicate Rows

August 14, 2009
Pinal Dave
SQL Tips and Tricks
SQL Function, SQL NULL, SQL Scripts, SQL Server

SUM DISTINCT totals different amounts without checking order identity. I’d establish the row grain first. Compare equal-priced orders, repeated copies and missing amounts.

Read More
Previous 1 … 5 6 7 8 9 10 11 12 Next
  • Books
  • Testimonials
  • Privacy Policy

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