Select customerID,productCategorID,count(*) 
   From Customers group by customerID,productCategorID
   order by customerID,productCategorID

解决方案 »

  1.   

    select top 1 productCategorID,count(*) as js from Customers group by productCategorID order by js desc
      

  2.   

    select top 1 productCategorID,count(*) as js from Customers group by productCategorID order by js desc
      

  3.   

    select A.productCategorName from productCategor A,Customers B where A.productCategorId=B.productCategorId
      

  4.   

    select customerID as 顾客, max(数量) as 最喜欢商品
    (
    Select customerID,productCategorID,count(*) as 数量 
       From Customers group by customerID,productCategorID
    )as ttt
    group by ttt.customerID