SQL statements can involve arithmetic expressions that use decimal data types of different precisions (the total number of digits, both to the left and to the right of the decimal point) and scales (the number of digits of the fractional component). The precision and scale of the resulting decimal type depend on the precision and scale of the operands.
ls + rs
31 - lp + ls - rs
max(max(ls, rs), 4)
max(ls, rs)
11.0/1111.33 // 31 - 3 + 1 - 2 = 27
lp + rp
2 * (p - s) + s
lp - ls + rp + max(ls + rp - rs + 1, 4)
max(lp - ls, rp - rs) + 1 + max(ls, rs)