A Correlated Subquery references the outer query. I use a stock-item comparison after the earlier single-table aggregate lesson.
SQL SERVER – Two Different Requirements for a Single Table Subquery
A subquery can compare rows with an aggregate from the same table. A junior DBA asked about this over lunch.
How to Create an Empty Table and Fool Optimizer to Believe It Contains Data? – Interview Question of the Week #204
How do you create an empty table and fool the optimizer into thinking it has data? Nobody asked me that in 20 years, but I use this trick in Health Checks.






