x
a b c
1 2 3
1 2 2
1 3 3
2 3 4
2 3 5
i want to find all same a+b’s
for that data my result should be
1 2 3 (look a and b)
1 2 2 (look a and b) they are same so should be in the result
**
2 3 4 (look a and b)
2 3 5 (look a and b) they are same so should be in the result
*
select count(a),a,count(b),b from Table A
group by a,b
having count(a)>1
and count(b)>1
That works like that I can see which ones are like that. But I want to see RAW data.
How can I see all data with that having clause ? Because that table have lots of columns and I dont want to group by them. I only want group by a and b and see all the columns .
Advertisement
Answer
You can use window functions:
select t.*
from (select t.*, count(*) over (partition by a, b) as cnt
from t
) t
where cnt > 1;