Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to do this in View.
Message
De
10/07/2003 08:28:06
 
 
À
10/07/2003 05:06:22
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Divers
Thread ID:
00808770
Message ID:
00808802
Vues:
17
You can use a derived table to UNION the two tables together and then your standard aggregate/group by syntax to pull everything together
SELECT x.name, SUM(x.totalservice)
FROM (
 SELECT name, totalservice FROM a
 UNION
 SELECT name, totalservice FROM b) AS x
GROUP BY 
 x.name
ORDER BY 
 x.name
-Mike

>Hi to all,
>
>I have here two tables,
>
>
>   Table A                    Table B
>
>   TOTALSERVICE   NAME        TOTALSALES   NAME
>     500          A              100       A
>     600          B              300       B
>     700          C              400       D
>
>
>
>and wanted to produce the following output
>
>
>   TOTALSALESSERVICE    NAME
>        600             A
>        900             B
>        700             C
>        400             D
>
>
>Great ideas are very much welcome.
>
>Looking forward for an answer.
>
>Noel
Michael Levy
MCSD, MCDBA
ma_levy@hotmail.com
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform