Select customerID,productCategorID,count(*)
From Customers group by customerID,productCategorID
order by customerID,productCategorID
From Customers group by customerID,productCategorID
order by customerID,productCategorID
(
Select customerID,productCategorID,count(*) as 数量
From Customers group by customerID,productCategorID
)as ttt
group by ttt.customerID