Select the 10 Worst-Selling Products Sample

JavaScript Editor js editor     Web development 



Main Page

File: ...\Samples\Data\Worstten.qpr

This query displays the 10 worst-selling products based on sales recorded in the Order Items table. The query uses the TOP n feature of the SELECT statement, and, because the default order is from smallest to largest, ordering by the sum of price and quantity returns the 10 lowest values.

В Copy Code
SELECT TOP 10 Products.prod_name,;
  SUM(Orditems.unit_price*Orditems.quantity);
 FROM testdata!products INNER JOIN testdata!orditems ;
   ON Products.product_id = Orditems.product_id;
 GROUP BY Products.prod_name;
 ORDER BY 2

See Also



JavaScript Editor js editor     Web development