2013-06-11 65 views

回答

2

要找到最暢銷的車:

select top 1 c.name 
from cars c 
join sold s 
on  s.CarID = c.ID 
group by 
     c.Name 
order by 
     sum(Price * SoldUnits) desc 

找車用最大的單一銷售:

select top 1 c.name 
from cars c 
join sold s 
on  s.CarID = c.ID 
order by 
     Price * SoldUnits desc 
+0

那麼容易,有人用SQL的expirience :)。謝謝,完美! –