Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi all,
I have two tables like:-
table1:
area,city,month
x,delhi,1
y,gurgoan,2
z,mumbai,3
concatination
table2:
id,name,branch,salary,month
1,rahul,a,100,1
2,amit,b,200,2
1,rahul,b,100,1
i am doing concatination between two table. if i remove branch (distinguish between rows of 2nd table) column then
sum(salary)= 300 which is worng
if i take all fields remain same then
sum(salary)= 400 which is right.
Some one tell me how it is happening.
Thanks,
Narender
Hi,
Can you please supply more details.
Where are you doing the sum(Salary)
Maybe supply a sample qvw?
Mark
Can you share sample data and Expected output ?
Regards,
Nagarjuna
because both table are associating by month field
1,rahul,a,100,1
1,rahul,b,100,1
rahul is having two branch a and b.. So if you remove branch, it would be one record only...
Hi Narendar,
I get the correct answer with this script both when I include the branch field or not:
Table1:
LOAD * INLINE [
area, city, month
x, delhi, 1
y, gurgoan, 2
z, mumbai, 3
];
Concatenate(Table1)
//LOAD * INLINE [
// id, name, branch, salary, month
// 1, rahul, a, 100, 1
// 2, amit, b, 200, 2
// 1, rahul, b, 100, 1
//];
LOAD * INLINE [
id, name, salary, month
1, rahul, 100, 1
2, amit, 200, 2
1, rahul, 100, 1
];
In your script is it possible that your second table is being loaded with a DISTINCT clause? That would reduce it to
id, name, salary, month
1, rahul, 100, 1
2, amit, 200, 2
if branch was omitted but if the branch field was included the table would be
id, name, branch, salary, month
1, rahul, a, 100, 1
2, amit, b, 200, 2
1, rahul, b, 100, 1
But the tables are being concatenated not associated by month as a key field.
it's displaying 400,right! how u got 300 first?
Hi All,
Thanks for your reply.
I have created table 2. via cross table.During this creation i have taken all columns include branch but in last i have removed columns like branch.I think this is due to cross table.So i have taken all columns and got right result.