【发布时间】:2014-05-08 12:10:45
【问题描述】:
我有一张桌子author_data:
author_id | author_name
----------+----------------
9 | ernest jordan
14 | k moribe
15 | ernest jordan
25 | william h nailon
79 | howard jason
36 | k moribe
现在我需要结果为:
author_id | author_name
----------+----------------
9 | ernest jordan
15 | ernest jordan
14 | k moribe
36 | k moribe
也就是说,对于出现重复的名称,我需要 author_id。我试过这个说法:
select author_id,count(author_name)
from author_data
group by author_name
having count(author_name)>1
但它不起作用。我怎样才能得到这个?
【问题讨论】:
标签: sql postgresql duplicates aggregate-functions window-functions