By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,248 Members | 882 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,248 IT Pros & Developers. It's quick & easy.

Getting a best selling brands list

P: 1
I know this should be easy but for some reason I have hit a blank. I am basically trying to get a list of the best selling brands for a SQL database. I have three tables: Brand, Product, Orders

I need to select the top 40 selling brands and the total number of all that brands products sold.

This is what I have so far but it isn't counting the products sold properly.
Expand|Select|Wrap|Line Numbers
  1. SELECT DISTINCT TOP (40) Brand_Name, products_Sold
  2. FROM Products 
  3. INNER JOIN  Orders ON Products.ID = Orders.ProdID 
  4. INNER JOIN  Brand ON Products.brandID = Brand.ID
  5. ORDER BY products_Sold DESC
  6.  
Feb 13 '07 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.