SELECT count(*), lower(name), number
FROM tbl
GROUP BY lower(name), number
HAVING count(*) > 1;
input tb1
slno name number
1 aaa 111
2 Aaa 111
3 abb 221
4 Abb 121
5 cca 131
6 cca 141
7 abc 222
8 cse 222
This query can just find the duplicates in the number and names which are same but it wont be able find the duplicates in the 3 and 4th row!!!
SELECT count(*), lower(name)
FROM tbl
GROUP BY lower(name)
HAVING count(lower(name)) > 1
this query can find all the duplicates in name!!! it works perfectly
SELECT count(*), number
FROM tbl
GROUP BY number
HAVING count(number) > 1
this query can find all the duplicates in number!!! it works perfectly
I want a query which can find all the duplicates in both name and number whether the name consists of lower case and upper case
output
name number count
2 111 aaa
2 --- abb
2 --- cca
2 222 ---
Updated question
"Get duplicate on both number and name" … "name and number as different column"
Rows can be counted twice here!
-> sqlfiddle
Original question
The problem is that the query groups by
As row 3 and 4 have a different
number, they are not the same for this query.If you want to ignore different numbers for this query, try something like: