We’ve all seen it: the massive, deeply nested SQL query with subqueries inside subqueries. It’s a nightmare to debug and usually performs terribly. Early in my career, I wrote queries like that. Then ...
I reviewed a SQL query yesterday… 200+ lines. 3 nested subqueries. Took 12 minutes to run. I replaced it with 30 𝐨𝐝𝐝 𝐥𝐢𝐧𝐞𝐬 𝐮𝐬𝐢𝐧𝐠 𝐰𝐢𝐧𝐝𝐨𝐰 𝐟𝐮𝐧𝐜𝐭𝐢𝐨𝐧𝐬. Same result. Faster.
-- a subquery is a query that is nested inside another query. -- SQL subqueries are also called nested queries or inner queries, while the SQL statement containing the subquery is typically referred ...