【发布时间】:2018-05-31 10:53:13
【问题描述】:
我需要一些帮助,我相信你们知道怎么做: 让我们从表结构开始:
author(name, nationality, Gender);
article(title, year, conference);
publication(articleTitle, authorName);
我需要知道发表文章最多的作者的性别。顺便说一句,我使用的是 PostgreSQL,不知道这是否重要。
这是我的想法:
select gender from author
join publication on(name = authorName)
having (count(articleTitle) = max(count(articleTitle)))
group by gender
现在,我知道我不能使用嵌套聚合函数,这就是我尝试使用嵌套选择的原因,例如 select gender where gender in (another select) 但我没有设法避免聚合函数问题。
希望您能帮帮我,谢谢
【问题讨论】:
-
样本数据和期望的结果会有所帮助。
标签: sql postgresql aggregate-functions