Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Upgrading, GROUP BY question
Message
De
28/04/2008 17:54:21
Mike Yearwood
Toronto, Ontario, Canada
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
01313609
Message ID:
01313659
Vues:
10
>I'm upgrading a VFP7 app to VFP9. I understand that all non-agregate fields should be included in the GROUP BY clause. Am I mistaken to assume that the primary group should be listed first? If the other fields are included only to make the select work, does it matter whatorder they are listed in?
>
>Is there a downside to listing many fields in the GROUP BY clause?
>
>Is there a better (or proper) way to handle this?

I believe the suggestions to use min and max on non-aggregate fields is not really good practice. IMO it's basically a workaround. What exactly does MAX(REP_NAME) mean?

I think, most of the time, you should either do your sums in a separate query order as a subtable and use joins to put everything together.

select ;
rep_pk, ;
rep_id, ;
rep_name, ;
gross_sales.gross_amount ;
from salesreps ;
inner join ;
(select sal_repfk, sum(sal_amount) as gross_amount from sales group by sal_repfk) gross_sales ;
on sal_repfk = rep_pk
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform