By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
CREATE TABLE data1(
codes int
);
INSERT INTO data1(codes)
VALUES
(100),
(100),
(007),
(100),
(004),
(004),
(000)
Records: 7 Duplicates: 0 Warnings: 0
select codes, count(*) as duplicate
from data1
group by codes
having count(*)<>1
order by duplicate desc
codes | duplicate |
---|---|
100 | 3 |
4 | 2 |