Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Simple Min Statement

Author  Topic 

ckuo@kahluadesigns.com
Yak Posting Veteran

58 Posts

Posted - 2002-09-16 : 17:18:50
This is probably a simple statement, but it escapes me. How do I return the lowest Price where the productcode is the same. Here is a sample table.

PRODUCTS
ProductID---ProductCode---Price
1-----------101-----------100
2-----------101-----------140
3-----------101-----------90
4-----------102-----------200
5-----------102-----------300

I would like to return
ProductCode---Price
101-----------90
102-----------200

Thanks.

tool
Starting Member

26 Posts

Posted - 2002-09-16 : 17:26:58
This should do it:

SELECT ProductCode, MIN(Price)
FROM Products
GROUP BY ProductCode

Go to Top of Page
   

- Advertisement -