Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MYSQL Select Problem - Top 10 Selling Products 1

Status
Not open for further replies.

kennygadams

Programmer
Jan 2, 2005
94
0
0
US
Any help is very much appreciated!

I have an "orders" table with an "item_number" field which has many duplicate records.

I want to select the top ten duplicated item numbers in this orders table and would also like to get the total number of times each record was found in the table.

I'm putting together a dynamic webpage, with PERL and MYSQL, which lists the top 10 selling images at
Here is the SQL statement that I have so far:

Code:
SELECT item_number FROM orders LIMIT 10

Kenny G. Adams
 
top ten duplicated item numbers in this orders table and would also like to get the total number of times each record was found in the table"
Code:
SELECT item_number
     , COUNT(*) AS daCount
  FROM orders
GROUP
    BY item_number
HAVING daCount > 1
ORDER
    BY daCount DESC LIMIT 10

r937.com | rudy.ca
Buy my new book Simply SQL from Amazon
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top