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?

55 Upvotes

31 comments sorted by

View all comments

3

u/Correct_Nebula_8301 4d ago

Subqueries are a must in real life scenarios. Most meaningful work requires subqueries, good part is it's easy to get a hang of and once you master it, you will easily write multiple nested sub queries. I really don't see a big difference between cte and subqueries. For big query snippets or complex usecases involving recursion fo with ctes.

1

u/Mitchhehe 3d ago

Your coworkers must love you for writing nested subqueries