Hi.

I have a large database, and am counting the contents of a particular column covering every record (some numbers have a decimal place, they are stored as TINYTEXT - (there was a reason at the time... 🙁 ).

I am using SUM( ) to add them all up, it was working fine untill a few days ago when it started reeturning an exponential, i.e. 9.88E16

I was then advised to use printf("%f", $var); which made the number slightly more readable.

The problem now is that is displays a rediculously large number! Nothing like what is expected.

Perhaps 1 or 2 million is about right, but this displays 16 or so numbers then 4 decimal places (all 0!).

Is there any way i can get this more accurate? Or will I need to itterate through every column and use PHP to add them up every time the page loads?

Thanks for your time!!
K.

    It might be using SUM() on a text field having unexpected results. Try ...

    SUM(0+field)

    ... rather than just ...

    SUM(field)

    ... in the SQL.

    Paul.

      Nope, it returns the same 🙁

      It has always worked on the text field, untill now (there are over 11,000 rows, each averaging 12,000 in the column counted)

      Are there any other ideas?
      Thanks again.
      K.

        Write a Reply...