Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Select maximum value from a table
Message
De
28/05/2002 07:26:37
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivie
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00661874
Message ID:
00661920
Vues:
28
>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

How about using TOP 1?
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform