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

前端 未结 2 1696
眼角桃花
眼角桃花 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:19

    Use GROUP BY like this

    SELECT
        `A`,
        `B`,
        COUNT(*) AS `Count`
    FROM
        `table`
    GROUP BY
        `A`, `B`
    ORDER BY
        `A`
    

提交回复
热议问题