一直在搞乱 Volusion 商店的查询,试图按品牌获得最畅销的 sku……我已经这样做了,但我怎么也只显示前 10 个 PER 品牌……
如果我添加前 10 名,则它只有 10 行期间。
select
products_joined.ProductManufacturer as brand,
Sum(OrderDetails.ProductPrice * OrderDetails.Quantity) AS TotalSold,
OrderDetails.ProductCode as sku
from
orderdetails, orders, products_joined
where
products_joined.ProductCode = OrderDetails.ProductCode
and Orders.OrderID = OrderDetails.OrderID
and Orders.OrderDate BETWEEN getdate() - 90 AND getdate()
and Orders.OrderStatus <> 'Cancelled'
and products_joined.ProductManufacturer is not null
group by
products_joined.ProductManufacturer, OrderDetails.ProductCode
order by
products_joined.ProductManufacturer,
Sum(OrderDetails.ProductPrice*OrderDetails.Quantity) DESC