Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Fastest method for union of two selects
Message
 
To
21/11/2006 22:13:56
General information
Forum:
Microsoft SQL Server
Category:
Stored procedures, Triggers, UDFs
Environment versions
SQL Server:
SQL Server 2000
Miscellaneous
Thread ID:
01171624
Message ID:
01171645
Views:
11
>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.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform