Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Unions in SQL Select
Message
De
13/07/2004 00:25:38
 
 
À
12/07/2004 19:24:24
John Tomblin
Service Station Systems, Inc.
San Jose, Californie, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00923488
Message ID:
00923542
Vues:
20
I think you have to use two queries:
after your first select sql statement, try:

select cnt(jobs) as jobs;
from JobTot;
into cursor JobTot2

Florin

>I have two identical tables, one for jobs we are currently working on called OpenJobs >and another containing invoiced jobs called DoneJobs.

>There are many times when I need to get the total number of jobs that match some >criteria from both tables. In the following example, I simply need the total number of >jobs within a date range:

>select cnt(Job) as Jobs from OpenJobs;
>where between(GetJob("MaxDate", Job), BDate, EDate) and !deleted();
>union all select cnt(Job) as Jobs from DoneJobs;
>where between(GetJob("MaxDate", Job), BDate, EDate) and !deleted();
>group by 1;
>into cursor JobTot

>I am trying to get a single record with the total number of jobs. The group by clause >here is illegal. You can't group by an aggragate column. So I add an additional field >to both selects: "X" as X and group by that column. It produces two records one from >OpenJobs and one from DoneJobs.

>What syntax can I use to get one record with the total of both tables?
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform