how to make a query to find the company with large number of selli

G

ghost

Hi
I have two tables, one for the companies' info and one for t selling
In the selling table there is data for customers, companies, prices etc.
What I want to do is making a query to know which company has the large No.
of selling.
Can any body help me plzzzz
 
J

Jerry Whittle

What do you mean by "which company has the large No. of selling"? Most sales?
Largest dollar amounts? Most items? In other words, which field determines
"large"?
 
M

Michel Walsh

Depends if you already have the count of transactions, or not, in the table.

If you have:


SELECT company
FROM tableName
GROUP BY company
HAVING LAST(numberOfTransaction) = (SELECT MAX(numberOfTransaction)
FROM
tableName)


or, even simpler:


SELECT TOP 1 company
FROM tableName
GROUP BY company
ORDER BY LAST(numberOfTransaction) DESC



If the number of transactions has to be computed as the number of rows, in
the table, then:


SELECT TOP 1 company
FROM tableName
GROUP BY company
GROUP BY COUNT(*) DESC




Hoping it may help,
Vanderghast, Access MVP
 
Top