1

consider

create table pairs (number a, number b)

where the data is

1,1
1,1
1,1
2,4
2,4
3,2
3,2
5,1

what query gives me all unique pairs plus a column representing the number of times that pair appeared. ie:

1,1,3
5,1,2
2,4,2
3,2,1

Note: This is SO question Distinct pair of values SQL but with the added "count" column requirement

code_monk
  • 9,451
  • 2
  • 42
  • 41

1 Answers1

2
select 
    a,b,count(*) c
from 
    pairs
group by 
    a,b
Alex
  • 2,247
  • 1
  • 27
  • 37