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 2008 Forums
 Transact-SQL (2008)
 Combine two tables without UNION

Author  Topic 

imrul
Starting Member

36 Posts

Posted - 2011-06-05 : 08:56:25
I have following two tables

Table_1

Mem_Id Trx_Dt Amount
------------------------------
1 2011-01-01 10000
1 2011-01-15 5000


Table_2

Mem_Id Trx_Dt Amount
---------------------------------
1 2011-01-06 0
1 2011-01-16 150
1 2011-01-18 150
1 2011-01-24 250
1 2011-01-29 100

I need the Output like bellow, without using the UNION operator

Mem_Id Trx_Dt T_1Amount T_2 Amount
-------------------------------------------------------
1 2011-01-01 0 10000
1 2011-01-06 0 0
1 2011-01-15 0 5000
1 2011-01-16 150 0
1 2011-01-18 150 0
1 2011-01-24 250 0
1 2011-01-29 100 0


1. Trx_Dt will be combined from both table and will be in an sequential order.
2. Amount from two tables will in two different column


Can any one help?

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-06-05 : 09:05:01
is this a homework question? also why you want solution without using union?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -