1

こんにちは、私の仕事について聞きたいことがあります

select * from 
  (Select m.Brand,u.Color,Count(Unit)as [Total unit] 
   from Brands m 
   inner join Products u on m.BrandID=u.ProductID 
   Group by m.Brand ,u.Color 
   with cube
   )as Pvt 
   PIVOT ( Sum([total unit]) 
   For Color IN ( [Black],[White],[Gray],[Silver],[Orange],[Dark Blue] ) 
   )AS Pivot_Table

ブランドの合計と色の合計を表示したいのですが、このコードは各色を計算し、ブランドごとにすべての色を数えるだけです

Total Brand と Total Color を取得するにはどうすればよいですか?

4

0 に答える 0