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 |
Ratz03
Starting Member
27 Posts |
Posted - 2014-10-07 : 18:09:28
|
hi experts,i am new to sql server development. I have to build reconciliation query and report from one table to another. See sample problem with table and report output needed. please help me with the query or stored procedure table 1 pk name age salary 1 abc 7 98 2 asd 2 56 3 xyz 3 10 table 2 pk name age salary1 abc 1 192 asd 2 87 3 xyz 4 987 Report name age salary delta table 1 table 2 table 1 table 2 table 1 table 2 abc abc 7 1 98 19 80 |
|
Bustaz Kool
Master Smack Fu Yak Hacker
1834 Posts |
Posted - 2014-10-07 : 18:40:36
|
Why is 'abc' included in the results but not the others? No amount of belief makes something a fact. -James Randi |
|
|
Ratz03
Starting Member
27 Posts |
Posted - 2014-10-08 : 03:51:49
|
quote: Originally posted by Bustaz Kool Why is 'abc' included in the results but not the others? No amount of belief makes something a fact. -James Randi
all rows need to come up, including asd and xyz. |
|
|
Bustaz Kool
Master Smack Fu Yak Hacker
1834 Posts |
Posted - 2014-10-08 : 11:35:55
|
[code]select t1.name, t2.name, t1.age, t2.age, t1.salary, t2.salary, t1.salary - t2.salary Deltafrom table t1inner join table2 t2 on t1.name = t2.name -- I'm guessing that the linkage is on name instead of id but you'd know better...[/code] No amount of belief makes something a fact. -James Randi |
|
|
|
|
|