SQL - 我可以有一个Group By子句后,一个选择?
问题描述:
For example:
Select max(date)
From table A
Where max(date) < any (select..
...)
Group By Book_Name,Client_Name
因此, max(日期)
字段可以与 Nestled Select
return,好像已经创建了更大的Select的分组。
So the max(date)
field could be compared to the Nestled Select
return, as if the grouping of the greater Select was already made.
答
HAVING
子句。
Select Book_Name,Client_Name, max(date)
From table A
Group By Book_Name,Client_Name
HAVING max(date) < any (select..
...)
我删除了对其他答案的引用。我不认为这是正确的,并没有真正的帮助,因为我认为HAVING是你需要的。
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.