Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Select maximum value from a table
Message
From
28/05/2002 04:19:05
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Select maximum value from a table
Miscellaneous
Thread ID:
00661877
Message ID:
00661877
Views:
56
I would like to know how i can get the record in a table with a certain value that is the maximum.

I have the following data in a table:

lh_recno lh_porg lh_price lh_bales
700555 360010A 3180.00 4
700255 360010A 3480.00 5
700545 360010A 1180.00 1
700534 360010A 5180.00 12
700553 360010A 3340.00 2
700531 360010A 310.00 4
700111 360010A 180.00 4

I want to be able to retreive the following record:
700534 360010A 5180.00 12

I have use sql as follows:

select bkwplot.lh_recno, lh_porg, max(lh_pprice) ;
from bkwplot;
group by 2

However, it does not return that record. It returns the correct max price, which is 5181, but the rest of the data is incorrect. Data returned would be
for example:

700531 360010A 5180.00 4 .

How do i get all the fields of the record with a the maximum price and not a mixed return value.

Regards,
Stuart
Stuart Reid

True nobility lies not in being superior to another man, but in being superior to one’s previous self
Next
Reply
Map
View

Click here to load this message in the networking platform