Compare EXISTS, IN, and JOIN for semi-joins, prevent duplicate customer rows, and handle NULL safely in exclusion queries.
Finding Top Earners: A T-SQL Challenge in SQL Server
The goal is to find the top three highest-paid (top earners) employees in each department and their corresponding department details.
SQL SERVER Challenge – Cumulative Total Calculation
Today we will see a very interesting SQL SERVER Challenge about Cumulative Total Calculation. During a recent Comprehensive Database Performance Health Check.
NOT IN With a NULL in the List Returns No Rows
See why NOT IN with a NULL returns no customers, then compare five sample rows, NOT EXISTS, an IS NOT NULL filter, and query plans.
Rewriting Correlated Subqueries as Window Functions
Replace correlated subqueries with windowed counts, dates, and running totals, preserve detail rows, and keep useful EXISTS filters.
Assertion Queries: Data Checks That Should Return Zero Rows
Let a short query find the order with no lines before a customer does. A small demo shows the failing keys, constraint error 547 and a clean repair.
Makers That Sell PCs but Not Laptops: HAVING With Conditional Counts
One WHERE clause cannot say ‘has a PC but no laptop’. Here are three queries that can, and the NULL trap.







