Daniel Kasak wrote:
>Mauricio Pellegrini wrote:
>
>
>
>>Hi,
>>I need to select the max value from a set of records but I also need the
>>primary key for that record.
>>
>>The problem is that the record id may not be the same as the record max
>>value for the column as in the following example:
>>
>>Table_x
>>
>>Id x_col date_col
>>1 1 2005-04-11
>>2 1 2005-03-10
>>3 1 2005-04-12
>>4 1 2001-01-01
>>
>>with
>> SELECT id, x_col, max(date_col)
>> FROM table_x
>> GROUP BY x_col
>>
>>I would probably get the following result
>>
>>Id x_col date_col
>>4 1 2005-04-12
>>
>>and what I would like to get is
>>
>>Id x_col date_col
>>3 1 2005-04-12
>>
>>
>>
>>
>>
>That *is* what you'd get. The max() function works on an individual
>column, not on all columns at once.
>
>
>
Oops. Disregard. Didn't think that one through.
See Rhino's response.
--
Daniel Kasak
IT Developer
NUS Consulting Group
Level 5, 77 Pacific Highway
North Sydney, NSW, Australia 2060
T: (+61) 2 9922-7676 / F: (+61) 2 9922 7989
email: dkasak@stripped
website: http://www.nusconsulting.com.au