Hi,
I have a sales database with hundreds of products, and I would like to run a report that shows me the TOP 20 selling products.
I have created the report, have the total sales ordered in descending order so the top selling items are at the top, but cannot get it to recognize the command to Limit the number or records it shows in the report.
Here's the code:
SELECT
SUM(testimport.QUANTITY) AS `Total Qty`,
testimport.REP_PERIOD AS `Date`,
product.product_description AS Product,
branch.branch_name AS Shop,
SUM((quantityprice)-vat_amt) AS `Total Sales`
FROM testimport
INNER JOIN product ON testimport.PRODUCT = product.product_tillref
INNER JOIN branch ON testimport.BRANCH = branch.branch_id
WHERE testimport.`TYPE` ='PAID'
GROUP BY testimport.REP_PERIOD, product.product_description, branch.branch_name, testimport.PRICE
ORDER BY (quantityprice)-vat_amt DESC
LIMIT 10
The last line is what I thought from reading about MySQL should go in, but it gives this error: ....check the manual that corresponds to your MySQL version for the right syntax to use near 'limi 0,200' line 13...
Using MySql 5.0.X
Many thanks,
Loredana