我有下表
people
person_id
first_name
last_name
我想抓取姓氏多次出现的所有人。 有人可以帮我这个。
答案 0 :(得分:0)
选择
PERSON_ID,
姓氏,
FIRST_NAME:
COUNT(*)
这
People
GROUP BY
Person_id,Last_Name,First_Name
HAVING
COUNT(*) > 1
答案 1 :(得分:-1)
Select *
from persons t1
Join (select t2t1. lastName, count(t2t1. *) 'counted'
from persons t2t1
Group by t2t1. lastName
Having count(t2t1. *) >1
) t2 on t1.LastName=t2. Lastname