Need to query distinct combination of two fields, along with a count that distinct combination occurs

前端 未结 2 1670
眼角桃花
眼角桃花 2021-01-21 11:45

What I need is a query on a table that would return distinct combinations of columns A and B, along with the count of how many times each combination occurs in the table. This w

2条回答
  •  滥情空心
    2021-01-21 12:10

    GROUP BY is your friend here:

    select a,b,count(*) from test
    group by a,b
    order by a
    

    SQLFiddle: http://sqlfiddle.com/#!9/062b0e/5

提交回复
热议问题