x***n 发帖数: 39 | 1 Suppose the primary key you wanna set is MyTable.ColumnA
Then
SELECT MAX(Duplicates), ColumnA
FROM
( SELECT COUNT(*) AS Duplicates, ColumnA
FROM MyTable
GROUP BY ColumnA); | b*e 发帖数: 3845 | 2 maybe this would be better
select count(*) as dup, columnA from myTable group by ColumnA
having dup>1
【在 x***n 的大作中提到】 : Suppose the primary key you wanna set is MyTable.ColumnA : Then : SELECT MAX(Duplicates), ColumnA : FROM : ( SELECT COUNT(*) AS Duplicates, ColumnA : FROM MyTable : GROUP BY ColumnA);
| c**t 发帖数: 2744 | 3 Why need nested w-c?
select count(*), ColumnA
from TABLE
group by ColumnA
having count(*) > 1
【在 x***n 的大作中提到】 : Suppose the primary key you wanna set is MyTable.ColumnA : Then : SELECT MAX(Duplicates), ColumnA : FROM : ( SELECT COUNT(*) AS Duplicates, ColumnA : FROM MyTable : GROUP BY ColumnA);
|
|