A decimal type field needs to be split up into ranges (intervals), calculated differently and then summed up.
This problem concerns field values, not rows.
So for a certain field (fieldX) in every row in a table:
FieldX < 0.013 <----remain just FieldX
FieldX >= 0.013 to 0.026 <----be multiplied with 50%.
FieldX > 0.026 <----be omitted.
Editorial comment: The examples below show for values in the closed-closed range [0.013, 0.026] that the expression is:
0.013 + (FieldX - 0.013) * 0.5
Then these ranges (intervals) or parts needs to be summed.
Example cases:
FieldX Result
-0.12 -0.12
-0.05 -0.05
+0.05 +0.05 — mismatch with specification
+0.011 +0.011
+0.014 +0.0135 = (0.013 + (0.014-0.013)*50%)
+0.021 +0.017 = (0.013 + (0.021-0.013)*50%)
+0.026 +0.0195 = (0.013 + (0.026-0.013)*50%)
+0.031 +0.0195 = (0.013 + (0.026-0.013)*50%) — mismatch with specification
I will hand out a Nobel prize to the genius who solves it!
The aggregates ignore NULL, which is tantamount to omitting it. Note that for SUM(), you could use 0.0 in place of NULL, but not for COUNT or AVG. The other way to ignore rows is to filter them out with a WHERE clause, of course: