Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
UNION SELECT
Message
 
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Miscellaneous
Thread ID:
00162880
Message ID:
00162971
Views:
25
>First, you need to encapsulate the SELECT for the UNION clause within parentheses. Second, why do this in two steps?
>
>Why not:
>
>SELECT s.Date AS DateFld, SUM(S.Count) AS SumNum ;
>  FROM SAMPLE S ;
>  INTO CURSOR Three ;
>UNION ALL (SELECT E.Date AS DateFld, E.Number AS SumNum ;
>  FROM Example E )
>
>
>I renamed fields because I'm allergic to using reserved names for fields - I'd avoid naming fields things like Count, Date, Number and the like to avoid confusing the interpreter, and avoid problems when going to another environment where the DML is pickier about reserved word collisions than VFP.

One modification:>
SELECT s.Date AS DateFld, SUM(S.Count) AS SumNum ;
  FROM SAMPLE S ;
UNION ALL (SELECT E.Date AS DateFld, E.Number AS SumNum ;
  FROM Example E ) ;
  GROUP BY whatever ;   && optional
  ORDER By whatever ;   && optional
  INTO CURSOR Three ;
All INTO, GROUP BY, and ORDER clauses go at the end of the SQL command.
Mark McCasland
Midlothian, TX USA
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform