I'm not understanding the purpose of subqueries in SQL, . I'm confused on how they differ from/how they're more beneficial than doing something like working it into your where statement, creating a case statement, or using a join or something? Can someone give me an example of when you might need a subquery? To my current understanding it's just helpful to do something like calculate an average and then also pull up other information from the table in the same query. I just simply don't understand, something isn't clicking right and I'm currently blaming my instructor because she's a new one and doesn't seem to explain anything in a way that makes sense to me.
Asked
Active
Viewed 41 times
0
-
1Does this answer your question? [Join vs. sub-query](https://stackoverflow.com/questions/2577174/join-vs-sub-query) – Shmiel Jun 22 '22 at 19:26
-
What kind of subquery? Some people refer to derived/inline tables as "subqueries". There are also correlated subqueries, scalar subqueries... – shawnt00 Jun 22 '22 at 19:37
-
In ways a subquery behaves something like a subroutine/function/procedure call if you're familiar with other languages. – shawnt00 Jun 22 '22 at 19:39