SQL: Finding single column duplicates & duplicate counts

Table NamesList INSERT statement

Tables with single column duplicates

Example with duplicates in the first column:

Finding the duplicates of the Idx column is easily done with:

SELECT
  T.*
, Tdup.IdxCount

FROM
NamesList AS T
JOIN
 (SELECT
    Idx
  ,
 COUNT(Idx) AS IdxCount
  FROM
NamesList
  GROUP BY
 Idx
  HAVING COUNT
(Idx) > 1
  ) AS Tdup
ON
T.Idx = Tdup.Idx
ORDER BY
T.Idx
;

and you will get this:

This SQL algorithm is valid with MS SQL Server, MySQL, PostgreSQL, SQLite, Firebird, AidAim SQLMemTable, Absolute Database and others.
With Paradox the subquery has to be substituted with an equivalent SQL query file.

Compatible with almost any database including Paradox and dBASE (and even MS Access) is the much simpler single column subquery

SELECT *
FROM
NamesList
WHERE
Idx IN
 
(SELECT
    
Idx
  FROM
NamesList
  GROUP BY
Idx
  HAVING COUNT
(Idx) > 1
 
)
ORDER BY
Idx
;