Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Query group by
Message
De
20/02/2017 06:37:02
 
 
À
20/02/2017 06:24:57
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Titre:
Versions des environnements
Visual FoxPro:
VFP 9
OS:
Windows 7
Network:
Windows XP
Database:
Visual FoxPro
Application:
Desktop
Divers
Thread ID:
01648180
Message ID:
01648183
Vues:
43
select * from table1 join (select id, max(qty) as qty from table1 group by id) table2 on table1.qty = table2.qty
you need to be sure that qty is unique per names; otherwise you'll need another sub-query on max(date) or whatever.


>Sir I have these codes
>
>
>	CREATE CURSOR table1 (id int,names c(10),date d,qty int)
>	INSERT INTO table1 VALUES (1,"ADMIN",{^2017-02-19},25)
>	INSERT INTO table1 VALUES (1,"ADMIN",{^2017-02-20},21)
>	
>	INSERT INTO table1 VALUES (2,"GENERAL",{^2017-02-17},29)
>	INSERT INTO table1 VALUES (2,"GENERAL",{^2017-02-21},14)
>	
>	SELECT id,MAX(names),MAX(date),MAX(qty)from table1 GROUP BY id
>
>	brow
>
>
>it show these wrong result
>
>1 ADMIN 2/20/2017 25
>2 GENERAL 2/21/2017 29
>
>But I need this
>
>1 ADMIN 2/19/2017 25
>2 GENERAL 2/17/2017 29
>
>The date that has greater qty
>
>Later on I want to use these codes in SQLSERVER 2008
>
>Please help
Thierry Nivelet
FoxinCloud
Give your VFP application a second life, web-based, in YOUR cloud
http://foxincloud.com/
Never explain, never complain (Queen Elizabeth II)
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform