Eric Lommatsch wrote:
Hello,
I am working with a query that calculates the averages of survey answers. The survey answers are stored in the database as int(11) fields. When I run the query the results that I am getting are being returned as string data. The query that I am working with is a data source for a Crystal Reports
reports. The average columns that are being returned by the query are used in
the report in fields that have been formatted for double values.
I am using MySQL 5.0.18 as the database. What would I have to do to get the
averages of Int columns to return as doubles, rather then having to change
all of my columns to be double columns?

I'm a little unclear where they're being returned as strings, and how you know they're strings and not floats. I think the math is done with floats, so even if your columns are floating-point, you'll get the same results. But in general, you can use CAST(), though CAST-ing to a floating-point isn't supported. I don't know why not.

SELECT CAST(AVG(col) AS DECIMAL(9,2)...

Baron

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to