Select Count using Min Aggregate function

lefe0102

New member
Local time
Yesterday, 21:14
Joined
Jan 21, 2010
Messages
2
Hi Guys...

I am new to Microsoft Access and am primarily using the database that talks to an SQL database that I am using in a C#/ASP environment.

Currently I am trying to create a query that would find the minimum price in a table however, I also want to count the amount of times that the minimum price is found.

So for the Min price...I would do something simple like:
SELECT MIN(`Price`)
FROM tPrice
WHERE ITEM = @ITEM

But I want the Count and the finding the min price in one command....so this is what I have currently...
SELECT MIN(`Price`)
FROM tPrice
WHERE ITEM = @ITEM
Group by price
Having Count(*) > 1

Obviously this isn't working...can anyone please point me in the right direction?

Thanks in advance...
 
SELECT TOP 1 tPrice.Price, Count(tPrice.Price) AS CountOfPrice
FROM tPrice
GROUP BY tPrice.Price
ORDER BY tPrice.Price;
 
SELECT TOP 1 tPrice.Price, Count(tPrice.Price) AS CountOfPrice
FROM tPrice
GROUP BY tPrice.Price
ORDER BY tPrice.Price;

Thanks!
I may have forgot to say that this must be for a specific Item so I would have to leave it as
SELECT TOP 1 tPrice.Price, Count(tPrice.Price) AS CountOfPrice
FROM tPrice
Where Item = @Item
GROUP BY tPrice.Price
ORDER BY tPrice.Price;

Cheers!
 

Users who are viewing this thread

Back
Top Bottom