Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello,
In my PDF /Screenshot, you will see what i try to do.
I tried to do this in SQL but unsuccessfully.
So i tried to divide "amount" per "nb_occurrence", but i have a problem with round : sometimes i have "3739.998" or "3738" or "3741" but never "3740"
In Eclispe, i did this :
import java.math.BigDecimal;
import java.math.RoundingMode;
public class div {
public static void main(String[] args) {
BigDecimal a, b;
BigDecimal reste, result;
Scanner scan = new Scanner(System.in);
a = BigDecimal.valueOf(scan.nextInt());
b = BigDecimal.valueOf(scan.nextInt());
result = a.divide(b, 3, RoundingMode.HALF_DOWN);
reste = a.subtract(result);
do {
b = b.subtract(new BigDecimal(1));
result = reste.divide(b, 3, RoundingMode.HALF_DOWN);
System.out.println("Résulat = " + result);
reste = reste.subtract(result);
System.out.println("reste = " + reste);
System.out.println("b = " + b+"\n");
} while (reste.compareTo(BigDecimal.ZERO) != 0);
}
}
and i tried to apply in TjavaRow/TjavaFlex :unsuccessfully
My Job is designed :
TpostgresqlInput ----row1---->TjavaRow----row2---->Tmap----row3--->TpostgreslOuput
I dont know a lot about Java...
So Can you help me ?
Regards,
Talend.pdf_20161207-0149.pdf