Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Filtering without Group By and Having ?
Message
De
07/12/2001 16:19:15
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00590837
Message ID:
00591463
Vues:
27
>Jay,
>
>Your alternate query would work fine and give the correct results, but it would be slower because your subquery is doing an unnecessary join. I am sure that under certain circumstance the complex subquery would be required.

Jim, you're right! Eliminating the join results in the following cleaner query:
SELECT Employee.* ;
  FROM Employee ;
  WHERE Employee.EmpID IN ;
     (SELECT EmpId ;
         FROM Training ;
         WHERE Program IN ("Orientation", "OSHA") ;
            GROUP BY EmpID ;
            HAVING COUNT (EmpID) = 2)
Thanks for the discussion.

I'm trying to get a better handle what SQL can do. The continuous refining of these queries allows some patterns to emerge that I haven't seen before.

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

Click here to load this message in the networking platform