Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Sql Highest Value with related field
Message
De
11/06/2015 08:12:08
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows Server 2012
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01620887
Message ID:
01620893
Vues:
41
I want to comment further on Borislav's reply. Although Set Enginebehavior 70 will make your select statement work, you may very well end up with the wrong data. That's what you see, and that's why this was fixed in later versions of VFP. So NEVER have Set Enginebehavior 70 (or 80) in your working code, only use it until you have fixed your select statements.

For further information, see http://fox.wikis.com/wc.dll?Wiki~EngineBehavior

>I have following table
>
>REP COUNTRY SALES
>01 IRL 600
>01 UK 500
>01 USA 400
>02 FRA 300
>02 GER 200
>02 ITA 100
>
>Set Enginebehavior 70
>Select Rep,Country, *,Max(Sales) as MySales from MyTable Group by REP ..results in
>01 USA 400
>02 ITA 100
>
>It picks the Sales ok but country arbitrarily (I think)
>
>The country I want is the country on the row with the Highest Sale i.e.
>01 IRL 600
>02 FRA 300
>
>Is there any way in SQL to do this ??
>
>Tia
>Gerard
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform