38.Shopper - 浏览产品和排序结果

Don也想要一个新的和流行的产品列表,也就是新上架的产品,并且已经被卖出去许多.

SELECT product.name, product.unitPrice, product.dateAdded, SUM(items.count) AS unitsSold 
        FROM purchases UNNEST purchases.lineItems AS items 
        JOIN product ON KEYS items.product 
        GROUP BY product 
        ORDER BY product.dateAdded, unitsSold DESC LIMIT 10

结果:

Last updated

Was this helpful?