Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Query group by
Message
De
21/02/2017 20:22:19
 
 
À
20/02/2017 07:14:06
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:
01648323
Vues:
60
>>Sir, your query is displaying strange result
>>
>>id_a names date qty_a id_b qty_b
>>1 ADMIN 2/19/2017 25 1 25
>>2 GENERAL 2/17/2017 29 2 29
>
>
>result is what you expect, you just need to specify the columns:
>
>select table1.*; && or table1.id, table1.names, etc.
> from table1;
>   join (select id, max(qty) as qty from table1 group by id) table2 on table1.qty = table2.qty
>
At the risk of looking foolish again.............

Your result works because qty is unique. Give the different names the same MAX(qty) and you'll wind up with extra rows. I believe you need
select table1.*; && or table1.id, table1.names, etc.
 from table1;
   join (select id, max(qty) as qty from table1 group by id) table2 on table1.id = table2.id AND table1.qty = table2.qty
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform