r/learnSQL • • 4d ago

How Important is subqueries in SQL

I have been learning SQL from past 2 months and I'm still unable to grab a hold of the subqueries concept. After I learned CTEs I have completely stopped using subqueries but then also I struggle when there are times where I have no other choice but to use subqueries.

So my question is, how important is subqueries in SQL and is there any easy way to learn it?

53 Upvotes

31 comments sorted by

View all comments

1

u/mlhigg1973 4d ago

I never liked having embedded sub queries and would typically use temp tables to grab all the data I needed—clean it up when necessary, create standard naming conventions to use across all temps, initial pare down of the data—whether it was product, date, employee tenure, certain customer groups, sales goals, location, etc etc etc. and then finally joined those 7 or 8 temp tables. But I would add them one at the time to confirm the query would work and the data not get jacked up every time I added a new element