Question:
SQL gurus - Which clause is not allowed in a subquery?
2008-05-24 16:18:37 UTC
This question is driving me crazy. Any SQL gurus out there?

Which clause is not allowed in a subquery?
a. From
b. Where
c. Group By
d. Having
e. Order By
f. Is Null
g. Is Not Null
h. Like

(Similar question)
Subqueries cannot
a. Use group by or group functions
b. Be used in multiple and/or predicates of the same outer query
c. Join tables
d. Appear in Select, Update, Delete, Insert statements
e. Retrieve from a table different than the outer query

Some of these answers are obviously wrong, but I cannot find any documentation anywhere about the other possibilities.

First one to show me the way (hyperlink with proof) gets 10 points!
Three answers:
Zee
2008-05-24 16:25:36 UTC
Subqueries cannot use group by or group functions. So "Group By" clause is not allowed in a subquery:



http://www.access-programmers.co.uk/forums/showthread.php?t=99476
St N
2008-05-24 16:30:43 UTC
I'm not a guru, but since grouping should be something you do before starting the query, I would think that hunting is right and grouping functions are not allowed in sub queries. Remember, computers are logical and own the copyright on "that does not compute".
Richard H
2008-05-24 16:32:26 UTC
Think about it....



Hint: a,b,d,e are fairly critical in any query (ok, a,b are essential, d and e are nice to be able to use).

f,g,h are fairly key as well.



b doesn't really make much sense in a sub query. Grouping doesn't make much sense in the sub query.





Apply the same reasoning to the second question and you realise b,c,d,e are all useful in a sub query but a isn't... :)


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...