Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 UNION subquery efficiency

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-06-29 : 09:37:18
J Teb writes "How efficient is it to use a UNION subquery in the FROM of a statement. I need to sum together a column that exists in two different tables. For instance a sales record that has data in a current working table tblSalesToday and a history table tblSalesHistory (very large table) both with a NumSales column. As of now I have a similar statement "Select Sum(TSS.NumSales) FROM (Select * FROM tblSalesToday UNION Select * FROM tblSalesHistory)" . This is a simple solution but seems extremely inefficient. Any advice would be helpful. thanks"
   

- Advertisement -