有趣的Join问题,源于SQL和SAS比较。# Database - 数据库
n*6
1 楼
tableA
id name salary06 ...
1 mike 1000
2 john 2000
4 tom 3000
tableB
id name income06 income07 ...
1 mike 1000 ...
2 john 3000
3 smith 3000
5 Leo 5000
Objective:
- Combine all the records from two tables into tableC(id, name, income)
- For a specific id, if B.income exists, use that for C.income.
- For a specific id, If B.income does not exist, use A.salary for C.income
Expected outcome tableC
id name income06 income07 ...
1 mike 1000 ...
2 john 3000
3 smith
id name salary06 ...
1 mike 1000
2 john 2000
4 tom 3000
tableB
id name income06 income07 ...
1 mike 1000 ...
2 john 3000
3 smith 3000
5 Leo 5000
Objective:
- Combine all the records from two tables into tableC(id, name, income)
- For a specific id, if B.income exists, use that for C.income.
- For a specific id, If B.income does not exist, use A.salary for C.income
Expected outcome tableC
id name income06 income07 ...
1 mike 1000 ...
2 john 3000
3 smith