Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Finding Max Salary
Message
De
13/04/2007 08:51:26
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Versions des environnements
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Divers
Thread ID:
01215436
Message ID:
01215455
Vues:
13
>>I have a table with the following fields sif_no, ClassCode, Salary. There are many ClassCodes for a policy. I want to get the ClassCode with the highest salary. See snippet of code below that I use. However, if there is a policy(sif_no) with two class codes with the same salary it will pick up both.
>>
>>I would like to have only 1 ClassCode returned in the query and it doesn't matter which ClassCode is selected.
>>
>>
>>
>>***get the max salary and class code
>>Select sif_no, class_code,  salary ;
>>	from tmpmem_class  a ;
>>	WHERE salary = ( Select Max(salary) From tmpmem_class b ;
>>	WHERE a.sif_no = b.sif_no)  ;
>>	INTO Cursor tmpmax
>>
>>
>>
>>
>>
>>Any suggestions.
>>
>>Gaylen
>
>
>***get the max salary and class code
>Select TOP 1 sif_no, class_code,  salary ;
>	from tmpmem_class  a ;
>	WHERE salary = ( Select Max(salary) From tmpmem_class b ;
>	WHERE a.sif_no = b.sif_no)  ;
>        ORDER BY class_code;
>	INTO Cursor tmpmax
>
>
Borislav

Unfortunately that only returns 1 record and not a record for each policy.

Sergey used a different approach in his reply and that seems to work.

Thanks
Gaylen
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform