开发者

Retrieving records fulfilling a condition using GROUP BY

开发者 https://www.devze.com 2022-12-15 14:11 出处:网络
I\'d like to only select the rows where开发者_JAVA百科 the count is greater than 1 (in other words the duplicates) right now from a few thousand records I am mostly seeing 1s with a few 2s and 3s here

I'd like to only select the rows where开发者_JAVA百科 the count is greater than 1 (in other words the duplicates) right now from a few thousand records I am mostly seeing 1s with a few 2s and 3s here and there

SELECT count( * ) AS `Number` , GI . *
FROM `GeneralInformation` AS GI
GROUP BY `FirstName` , `Surname` 

how can I do this?


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


Use the Having clause

SELECT count( * ) AS `Number` , GI . *
FROM `GeneralInformation` AS GI
GROUP BY `FirstName` , `Surname` 
HAVING count( * ) > 1
0

精彩评论

暂无评论...
验证码 换一张
取 消