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.
Author |
Topic |
niyaz4872
Starting Member
41 Posts |
Posted - 2013-01-10 : 03:21:10
|
following is my tables structuretable1 structure:id_1 count_101 204 109 501 6table2 structure:id_2 count_201 109 501 607 1following is sample results i wan'tid Count(count_1+count_2)01 1504 107 109 10 |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-01-10 : 03:24:52
|
[code]SELECT id,SUM(cnt) AS [Count]FROM(SELECT id_1 AS id,count_1 AS cntFROM table1UNION ALLSELECT id_2,count_2FROM table2)tGROUP BY idORDER BY id[/code]------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
|
|
|