Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Sum from fields in two tables
Message
De
16/11/2008 13:21:12
 
 
À
16/11/2008 12:57:35
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Versions des environnements
Visual FoxPro:
VFP 9 SP2
Divers
Thread ID:
01362166
Message ID:
01362170
Vues:
12
>I have to sum two fields. Same field name but in two different tables.
>
>Right now I sum and join but I end-up with two sums for the same Id.
>
>How do I sum everything without intermediate sums (because of the joins) ?
>
>I guess that "where in (select...) would be involved but I'm sot sure how to build this.

Like this, Denis ?
create cursor c1 ;
	( ;
		Id I ;
	)
	
	insert into c1 values (1)
	insert into c1 values (2)
	
	create cursor c2 ;
	( ;
		Id I ;
	)
	
	insert into c2 values (3)
	insert into c2 values (4)
	
	select sum(id) ;
		from	( select sum(id) as Id from c1 ;
					union all ;
				select sum(id) as Id from c2 ;
				)  as xxx ;
			
Gregory
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform