38.Shopper - 浏览产品和排序结果
Last updated
Was this helpful?
Last updated
Was this helpful?
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
结果:
{
"results": [
{
"dateAdded": "2013-05-11T15:52:18Z",
"name": "Briggs & Riley 13 Inch Slim Clamshell Briefcase",
"unitPrice": 175.2,
"unitsSold": 149
},
{
"dateAdded": "2013-05-11T15:52:18Z",
"name": "American Standard 2988.101.020 Concealed Trapway Cadet 3 Right Height Round Front Flowise 1.28 gpf Toilet with Seat, White",
"unitPrice": 279.95,
"unitsSold": 146
},
{
"dateAdded": "2013-05-11T15:52:18Z",
"name": "3M Indoor Window Insulator Kit, 1-Window",
"unitPrice": 18.03,
"unitsSold": 136
},
{
"dateAdded": "2013-05-11T15:52:18Z",
"name": "Achim Home Furnishings FTVGM30820 Nexus 12-Inch Vinyl Tile, Geo 16 Square Sandstone, 20-Pack",
"unitPrice": 14.25,
"unitsSold": 131
},
{
"dateAdded": "2013-05-11T15:52:18Z",
"name": "Ball Cap Buddy",
"unitPrice": 5.61,
"unitsSold": 131
},
{
"dateAdded": "2013-05-11T15:52:18Z",
"name": "Moen YB8099CH Mason Paper Holder, Chrome",
"unitPrice": 1.41,
"unitsSold": 130
},
{
"dateAdded": "2013-05-11T15:52:18Z",
"name": "Hardware House H10-6184 Bridgeport Series Single Handle Tub and Shower Mixer, Brushed Nickel",
"unitPrice": 69.99,
"unitsSold": 128
},
{
"dateAdded": "2013-05-11T15:52:18Z",
"name": "Darice 4-3/4-Inch Magnetic Manikin",
"unitPrice": 6.96,
"unitsSold": 128
},
{
"dateAdded": "2013-05-11T15:52:18Z",
"name": "Moonrays 91515 Turtles on a Log Solar-Powered Outdoor LED Light",
"unitPrice": 16.95,
"unitsSold": 125
},
{
"dateAdded": "2013-05-11T15:52:18Z",
"name": "Mr. Beams MB 542 Battery Powered Motion Sensing LED Remote Path Light, 2-Pack",
"unitPrice": 33.72,
"unitsSold": 124
}
]
}