Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Fastest method for union of two selects
Message
De
22/11/2006 02:33:31
 
 
À
21/11/2006 22:13:56
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Stored procedures, Triggers, UDFs
Versions des environnements
SQL Server:
SQL Server 2000
Divers
Thread ID:
01171624
Message ID:
01171645
Vues:
12
>I have two select statements which calculate daily in - out qty for given item from transaction file.
>As there is a sum() in the select the union is not working.
>I had to achive this using the temporary table. The process is slow. Is there any other way to achive this.
>
>
>Rajesh

I am not sure what you want, but there is no need to use TEMP table, just use derived one:
SELECT Id, SUM(Qty) AS Qty
       FROM (SELECT Id, Qty
                    From Table1
             UNION ALL  
             SELECT Id, Qty
                    From Table2) TblTest
       GROUP BY Id
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform