由买买提看人间百态

topics

全部话题 - 话题: income06
(共0页)
n********6
发帖数: 1511
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
o******5
发帖数: 29
2
Here is the Oracle code:
create table c
as
select nvl(a.id,b.id) id,nvl(a.name,b.name) name,nvl(b.income06,a.salary06)
income06
from a full outer join b
on a.id=b.id
order by 1;
I do not know whether you can use PROC SQL to achieve this same thing or not
.
o******5
发帖数: 29
3
I gave it a little more thought on this. In fact, you can use PROC SQL to do
this.
proc sql;
create table c
as
select coalese(a.id,b.id) as id,coalese(a.name,b.name) as name,coalese(b.
income06,a.salary06) as income06
from a full outer join b
on a.id=b.id
order by 1;
quit;
(共0页)