Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
358 views
in Technique[技术] by (71.8m points)

tsql - Why does Rozenshtein say that you can't use a GROUP BY clause in a subquery and its outer query?

In chapter 25 of The Essence of SQL, Dr. Rozenshtein says, "Given a query tree, it is prohibited to use aggregate functions and/or the GROUP BY or HAVING clauses in any two query blocks where one is a descendant of the other."

I often find myself writing subqueries in FROM clauses, but because of the above, I try to avoid grouping until I absolutely can't anymore. I've gotten conflicting results by putting GROUP BY clauses in the inner and outer queries — sometimes it works, but sometimes I get double grouping. When I ask people more knowledgeable than me, they usually just tell me that there is no such restriction, but that doesn't really answer my question. Rozenshtein is respected in the field, and he mentions the issue a few different times, which leads me to believe that there is some history there. Can someone give me a brief explanation?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...