I am running a select statement on an orders table (sql) . I want to select the top 5000 of the items that sold the most.- where the count of the item name appears the most.
How do I go about this?
thank you.
Printable View
I am running a select statement on an orders table (sql) . I want to select the top 5000 of the items that sold the most.- where the count of the item name appears the most.
How do I go about this?
thank you.
What is the table structure like? Basicly it is a Top N Order By Count(*)
Just ordernumber, itemid, itemname, date....
I need to select the top 5000 itemids which sold the most(appear the most in the table.)
thank you.
try this:
sql Code:
Select Top 5000 itemid,itemname,ordernumber,count(*) from tableName Group by itemid,itemname,ordernumber Order by count(*) desc
thank you.
You might want to leave off OrderNumber there... I think it will mess up the results.