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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query that will find most used # in any order

Status
Not open for further replies.

webware

Technical User
May 27, 2002
6
US
I need a query or maybe vbscript that will search my database without having a user input a # for a 3 digit # in any combination that was most freaquently used,2nd most freq. etc. for example: if the database contains 7 entries 325; 352; 235; 253; 532; 523; 234, the output should show that the most freq. used was 3 #'s containing 325. Can anyone help me with this? I am using microsoft access2002....I have tried a query using LIKE but I dont want the user to have to input a #... I am really a designer not a programmer so...Thanks to anyone who can help.
 
Test this in Northwind and see if it's what you are after. It categorizes the Quantity field in table Order Details and returns the most frequent order quantity.

SELECT top 1 Count([Order Details].Quantity) AS CountOfQuantity, [Order Details].Quantity
FROM [Order Details]
GROUP BY [Order Details].Quantity
ORDER BY Count([Order Details].Quantity) DESC;

To see the entire listing, remove 'top 1' from the first line of the SQL.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top