SQL - Can I have a Group By clause after a nestled Select?

跟風遠走 提交于 2019-12-13 10:22:23

问题


For example:

Select max(date)
From table A
Where max(date) < any (select..


                      ...)

Group By Book_Name,Client_Name

So the max(date) field could be compared to the Nestled Select return, as if the grouping of the greater Select was already made.


回答1:


What you want is typically done with the HAVING clause.

Select Book_Name,Client_Name, max(date)
From table A
Group By Book_Name,Client_Name
HAVING max(date) < any (select..


                      ...)

I removed reference to the other answer. I don't think it was correct and doesn't really help because I think HAVING is what you need.



来源:https://stackoverflow.com/questions/30147349/sql-can-i-have-a-group-by-clause-after-a-nestled-select

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!