Compartir a través de


Select the Top 10 Best-Selling Products Sample

File: ...\Samples\Data\Topten.qpr

This query displays the top 10 best-selling products based on sales recorded in the Order Items table. The query uses the TOP n feature of the SELECT statement. Because the order is set to DESCENDING, ordering by the sum of price and quantity returns the 10 highest values.

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 DESC

See Also

Tasks

Select the 10 Worst-Selling Products Sample

Solution Samples

Reference

Visual FoxPro Foundation Classes A-Z

Other Resources

Views and Queries Solution Samples