Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How Do You All Handle Group By Command
Message
De
02/08/2006 11:20:51
 
 
À
01/08/2006 18:15:48
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows 2000 Server
Database:
Visual FoxPro
Divers
Thread ID:
01141909
Message ID:
01142432
Vues:
22
>If you known that on the group the expression is constant, then
>min=max=any and these are equals:
>
>SELECT item,MIN(exp)  FROM test GROUP BY item
>SELECT item,MAX(exp)  FROM test GROUP BY item
>SELECT item,exp       FROM test GROUP BY item,exp
>SELECT item,exp       FROM test GROUP BY exp,item
>
>set engine 70
>SELECT item,exp FROM test GROUP BY item
>
>
>This is a very special case,
>and a lot of times it conceals a bad planning of the database;
>then it is difficult to justify the implementation of ANY()
>

Actually, I think this situation comes up most when you want to select several fields from a parent along with some information from a child. For example:
SELECT Customer.CustomerID, CompanyName, MAX(OrderDate) ;
  FROM Customer ;
    JOIN Order ;
      ON Customer.CustomerID = Order.CustomerID ;
  GROUP BY CustomerID
In this case, of course, either solution--adding the field to the GROUP BY or wrapping it with MAX()--works.

Tamar
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform