I have used this construction earlier:

select ID, max(valueA), ValueB, ValueC
from ....
group by ValueA

I have not seen it failing yet, but it isn't correct SQL and other SQL
implementations (such as Access) doesn't allow it. Future MapInfo versions
may also bark at this.

Regards
Uffe


----- Original Message ----- 
From: "Susan Yu" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, May 13, 2004 2:18 AM
Subject: MI-L [New Question] RE: MI-L Select Highest Value only in Table -
Multiple Records


> Hello everyone,
>
> I have a follow-up question since I'm doing something similar.  I hope
> someone has a simple answer that I'm not seeing.
>
> What if I wanted to select the RECORD with the highest value from a
> certain column?
>
> I have multiple columns where they would all have a value with the same
> IDs.  But not all the columns are consistantly the highest value.
>
> For example:
>
> ID     ValueA     ValueB    ValueC
> XYZ    20         30        40
> XYZ    30         15        20
> XYZ    40         11        10
> ABC    50         20        17
> ABC    22         30        10
>
>
> I would like to select only the records where ValueA is the higest
> (regardless of the values in ValueB and ValueC)
> I would like this result:
>
> ID     ValueA     ValueB    ValueC
> XYZ    40         11        10
> ABC    50         20        17
>
> I'm worried that if I used "group by ID", the query will return the ID,
> with the highest ValueA, but randomly pick the values for ValueB and
> ValueC.
>
> Is there a solution?  I would be grateful for any help.
>
> Thanks,
> Susan


---------------------------------------------------------------------
List hosting provided by Directions Magazine | www.directionsmag.com |
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
Message number: 11731

Reply via email to