Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi!
I have "field 1" and "field 2" in one table, I wand to take the sum from "field 1" and divide it with the sum of "field 2" and create "field 3" from it (wich should be the result of dividing the two others).
Table looks like this
ID | Field 1 | Field 2 | (non existing field 3) |
0113010031 | 13986 | 74 | 189 |
0113010031 | 15403,5 | 81,5 | 189 |
0113010031 | 19561,5 | 103,5 | 189 |
0113010031 | 23642,5 | 122,5 | 193 |
0113010031 | 24570 | 130 | 189 |
0113010031 | 24759 | 131 | 189 |
0113010031 | 28633,5 | 151,5 | 189 |
0113010031 | 28728 | 152 | 189 |
0113010031 | 29072 | 158 | 184 |
0113010031 | 29106 | 154 | 189 |
0113010031 | 29239,5 | 151,5 | 193 |
0113010031 | 30204,5 | 156,5 | 193 |
0113010031 | 31279,5 | 165,5 | 189 |
0113010031 | 32130 | 170 | 189 |
0113010031 | 33485,5 | 173,5 | 193 |
0113010033 | 2798,5 | 14,5 | 193 |
0113010033 | 4347 | 23 | 189 |
0113010033 | 12641,5 | 65,5 | 193 |
0113010033 | 23530,5 | 124,5 | 189 |
Please Help:)
Try this:
LOAD
ID,
[Field 1],
[Field 2],
[Field 1]/ [Field 2] as [Field 3]
FROM test.qvd;
So it would be equal to the table you showed us before, now if you want to have a record by ID, with the sum of field 1, the sum of field 2 and finally field 3 (sum (field1) / sum (field2)) would be as follows:
LOAD *,
[Field 1]/ [Field 2] as [Field 3] ;
LOAD
ID,
sum([Field 1]) as [Field 1],
sum([Field 2]) as [Field 2]
FROM test.qvd
group by ID;
Regards!!!
Try this:
LOAD
ID from original table,
sum(field1) / sum(field2) as field3
resident original table
group by ID;
Tab1:
Load
ID,
Field1,
Field2
from Db;
Load
sum(Field1)/(Field2) as field3
resident Tab1 group by ID;
Use like this
It doesn't look like you re summing them as the out put are different for one id
Load * , [Field 1]/[Field 2] as field3;
Load
ID, [Field 1], [Field2]
from Table_name;
Try this:
LOAD
ID,
[Field 1],
[Field 2],
[Field 1]/ [Field 2] as [Field 3]
FROM test.qvd;
So it would be equal to the table you showed us before, now if you want to have a record by ID, with the sum of field 1, the sum of field 2 and finally field 3 (sum (field1) / sum (field2)) would be as follows:
LOAD *,
[Field 1]/ [Field 2] as [Field 3] ;
LOAD
ID,
sum([Field 1]) as [Field 1],
sum([Field 2]) as [Field 2]
FROM test.qvd
group by ID;
Regards!!!
thanks to everyone for helping out!