我只想从几千条记录中选择计数大于1的行(换句话说,重复数字),我主要看到1s,其中有几个2s和3s
SELECT count( * ) AS `Number` , GI . *
FROM `GeneralInformation` AS GI
GROUP BY `FirstName` , `Surname`
我该怎么做?
答案 0 :(得分:9)
SELECT count( * ) AS `Number` , GI . *
FROM `GeneralInformation` AS GI
GROUP BY `FirstName` , `Surname`
HAVING count(*)>1
答案 1 :(得分:7)
使用Having子句
SELECT count( * ) AS `Number` , GI . *
FROM `GeneralInformation` AS GI
GROUP BY `FirstName` , `Surname`
HAVING count( * ) > 1