3 Replies Latest reply: Sep 18, 2014 5:33 AM by Manish Kachhia

# divide with 2 collumms/tables in 1

Hi guys,

can you tell me how can I divide with 2 tables ?

example:

Tab1:

ArtNo,

Cost, // here are amounts that costs with discount like: 550€ & -50€

Quantity, //here are all quantity like 25 and 25

FROM ..

Now I want to sum(cost)/sum(quantity).

Is it possible to use it in script?

Backend in expressions, it works.

• ###### Re: divide with 2 collumms/tables in 1

Hi

Try like this

Load DocNo, ArtNo, Cost, Quantity, Cost/Quantity As Percentage From ... ;

• ###### Re: divide with 2 collumms/tables in 1

You have to use group by

ArtNo,

sum(cost)/sum(quantity)

FROM ..

Group by //Include all columns other than cost and quantity

DocNo,ArtNo

• ###### Re: divide with 2 collumms/tables in 1

You can do as below

1)

Tab1:

ArtNo,

Cost,

Quantity,

Cost/Quantity as YourNewFieldName

FROM ..

2)

Tab2:

DocNo,

ArtNo,

SUM(Cost)/SUM(Quantity) as YourNewFieldName

Resident Tab1

Group By DocNo, ArtNo...

But the 1st Method is more efficient...