Table1:
Person_ID Name Salary_Revisions
1 Test1 100
1 Test1 200
2 Test2 300
2 Test2 400
Table2:
Person ID Department
-------------------------- ----------------
1 Physics
1 Chemistry
2 Maths
I would like to get the result like:
Person_ID Name Salary_Revisions Department
--------------------- ------------------ ---------------------- --------------
1 Test1 100 Physics
1 Test1 200 Chemistry
2 Test2 300 Maths
2 Test2 400
Actual:
Person ID Name Salary Revisions Department
------------------ --------- --------------------- ----------------
1 Test1 100 Physics
1 Test1 200 Physics
1 Test1 100 Chemistry
1 Test1 200 Chemistry
2 Test2 300 Maths
2 Test2 400 Maths
Could you please help me to implement like the expected result?
While implementing this I wrote a stored procedure by left joining Table 1 with Table 2 using person id. By executing the query in Database It returns like Actual result.
SQL Query:
SELECT table1.person_ID, table1.name, table1.salary_revisions, table2.department
from table1
left outer join table2 on table1.person_id=table2.person_id
Salary_Revisions = 400come from?? Doesn't seem to be in the base tables.... you need to explain your logic - it's not clearly obvious from just those bits of data you're showing us here...