0
if (preise.kond_basis_preis > 0,preise.kond_basis_preis, a.bruttopreis) as bruttopreis,
preise.kond_basis_preis,
a.bruttopreis as brutto

delivers as values:

4.659999847412109   
4.66    
4.66

What causes this?

Server Version: 5.7.22-0ubuntu0.16.04.1-log

O. Jones
  • 103,626
  • 17
  • 118
  • 172

1 Answers1

1

Floating point arithmetic causes this. Your first line contains an implicit computation.

Try

ROUND(if (preise.kond_basis_preis > 0,preise.kond_basis_preis, a.bruttopreis),2) as bruttopreis,

and you'll get the twp decimal places to the right of the . as you expect.

Read this. Is floating point math broken?

O. Jones
  • 103,626
  • 17
  • 118
  • 172