Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
UNION SELECT
Message
 
 
À
01/12/1998 16:12:46
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Divers
Thread ID:
00162880
Message ID:
00162971
Vues:
19
>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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform