Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
If I have two Tables, EMP and SALES and want to populate certain values. Can someone guide me how can I write joins and where ? How can I populate the Dimension value by creating a join of two or more tables ?
For eg.
EMP
EMPNO | NAME |
---|---|
1 | A |
2 | B |
SALES
EMPNO | CITY | SALES |
---|---|---|
1 | X | 100 |
2 | Y | 200 |
TO BE
RESULT
EMPNO | CITY | SALES | NAME |
---|---|---|---|
1 | X | 100 | A |
2 | Y | 200 | B |
Hi,
you can do it in script :
if you have loaded emp and sales
add in script :
inner join (emp) load empno,city, sales resident sales;
you can add : drop table sales
all fields will be in emp
regards
Thanks.. But this will create denormalized table isn't it ? Also, I will have to load the table everytime, I want to add any calculated column in any one of the tables.
Is my understanding correct ?
Hi,
Emp:
load * from Emp;
inner join(Emp)
load * from sales;
Join will keep the only first table along with all the columns from second table.
Yes, it will be denormalized table.
For any calculated columns from , you can just add that calculated column in the table.
Hope this helps
Thanks,
Pooja
Thanks all for the help. it worked.
Hi,
Well if you are looking to generate the resulted table basically you don't need to join those two tables.
Both table, if the EMPNO is common key then automatically both tables will be connected and you can get the result.
if you have only a few records in those tables it's ok to join two tables but if you have many records then Join will take time to load the data.
And one more thing if you want to load only those records of employees from the SALES table who are available in EMP table then you can you WHERE EXIST Condition.
Like :
Emp:
load * from Emp;
Sales:
load * from sales
where exist(EMPNO);
Thanks,
Mohammed Mukram