Count distinct values

前端 未结 5 1345

I have a data set asking a customer how many pets they have for example. Is there a way with one query I can count the distinct values (1,2,3, etc)? Thanks!

         


        
5条回答
  •  一向
    一向 (楼主)
    2020-12-07 18:04

    SELECT CUSTOMER, COUNT(*) as PETS 
    FROM table_name 
    GROUP BY CUSTOMER;
    

提交回复
热议问题