Developers often write subqueries where Joins would do, or the other way around. A short note on converting between the two, with links to my earlier examples.
SQL SERVER – Join Better Performance – LEFT JOIN or NOT IN?
LEFT JOIN or NOT IN: which one gives Join Better Performance? It depends on the data. Compare the two queries and their execution plans on AdventureWorks.
SQL SERVER – Simple Puzzle Using Union and Union All – Answer
The answer to yesterday’s Simple Puzzle Using Union and Union All, explained with an image. My UNION vs. UNION ALL article explains why it works.
Solving SQL Puzzles With Set-Based Thinking
Set-based thinking solves three SQL puzzles with grouping, anti-joins, and windows, then turns each solution into a repeatable query habit.
SQL SERVER – 2005 – Find Nth Highest Record from Database Table – Using Ranking Function ROW_NUMBER
Nicholas Paldino shared a neat way to find the Nth Highest Record from a table in SQL Server 2005 using the ranking function ROW_NUMBER. Here is his query.
SQL SERVER – How to Retrieve TOP and BOTTOM Rows Together using T-SQL – Part 3
Part 3 on how to retrieve TOP and BOTTOM rows together: Dave Arthur’s solution uses UNION ALL instead of an OR clause, and it is quite good.
SQL SERVER – How to Retrieve TOP and BOTTOM Rows Together using T-SQL – Part 2 – CTE
Part 2 of retrieving TOP and BOTTOM rows together: a reader’s solution using a CTE, the temporary result set introduced in SQL Server 2005.






