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
 SQL Server Development (2000)
 Min and Max Aggregate

Author  Topic 

hug
Starting Member

11 Posts

Posted - 2000-11-06 : 05:27:46
When you use the min() or max() how do you find the value of the other fields in the table for the resulting min/max value.

When aggregating information it makes no sense to be able to see the other fields for a count, sum or avg. But for min and max it does.

table A( id, price, code)

how would you return the code for the min(price) record in each group.

eg.
1 , $12, bbbb
1 , $11, aaaa
1 , $10, cccc
2 , $10, aaaa
2 , $11, dddd

you would want the results to be

1, $10, cccc
2, $10, aaaa

How can this be done ?





Edited by - hug on 11/06/2000 16:14:30
   

- Advertisement -