Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Filtering without Group By and Having ?
Message
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00590837
Message ID:
00591463
Views:
26
>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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform