使用GROUP BY检索满足条件的记录

Moa*_*oak 9 mysql group-by aggregate count having

我现在只想从几千条记录中选择计数大于1的行(换句话说是重复数据),我主要看到1s,其中有2s和3s在这里和那里

SELECT count( * ) AS `Number` , GI . *
FROM `GeneralInformation` AS GI
GROUP BY `FirstName` , `Surname` 
Run Code Online (Sandbox Code Playgroud)

我怎样才能做到这一点?

Mik*_*ffe 9

SELECT count( * ) AS `Number` , GI . *
FROM `GeneralInformation` AS GI
GROUP BY `FirstName` , `Surname` 
HAVING count(*)>1
Run Code Online (Sandbox Code Playgroud)


mop*_*oke 7

使用Having子句

SELECT count( * ) AS `Number` , GI . *
FROM `GeneralInformation` AS GI
GROUP BY `FirstName` , `Surname` 
HAVING count( * ) > 1
Run Code Online (Sandbox Code Playgroud)