Name Age Cut-off
--------------------------
Ram 22 89.50
Ganesh 22 66.00
Sam 22 92.00
Albert 22 89.50
Kannan 22 65.45
John 22 66.00
在上表中,Ram和Albert以及Ganesh和John具有相同的截止值。怎么能
我得到所有这些行?
最佳答案
SELECT a.*
FROM tableName a
INNER JOIN
(
SELECT `Cut-off`, COUNT(*) totalCOunt
FROM tableName
GROUP BY `Cut-off`
HAVING COUNT(*) > 1
) b ON a.`Cut-off` = b.`Cut-off`
为了获得更快的性能,请在列
INDEX
上添加Cut-off
SQLFiddle Demo