How can I count unique pairs of values in SQL?

前端 未结 4 918
别那么骄傲
别那么骄傲 2021-01-01 15:58

With the following sql statement I can get all unique values with their counts for a given column:

select column, count(column) as count 
         from table          


        
4条回答
  •  忘掉有多难
    2021-01-01 16:44

    You've almost got it correct... You just add an additional GROUP BY column like so:

    SELECT [first_name], [last_name], COUNT(*) AS [Count] 
    FROM [Table]
    GROUP BY [first_name], [last_name]
    ORDER BY [Count] DESC;
    

提交回复
热议问题