>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.