Link to home
Start Free TrialLog in
Avatar of SunnyX
SunnyX

asked on

mySQL. SQL query. Substitute for Numeric key word.

Let say I need to solve the problem :

With a precision of two decimal places, determine the average number of guns for the battleship classes.


SELECT AVG(numGuns+0.0)
FROM Classes
WHERE type = 'bb'

Open in new window


The query about work fine but show me result with more than 2 decimal points.

I need to write sql query that will be analog query below but will be work on mySQL server ( as far as I understand Numeric key word didn't work in mySQL server )
SELECT CAST ( AVG(numGuns+0.0) AS NUMERIC(10,2) )
FROM Classes
WHERE type = 'bb'

Open in new window


So how can I rewrite the query above in order that it'll work in mySQL server.
Thx in advance !
SOLUTION
Avatar of Francisco Igor
Francisco Igor
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of SunnyX
SunnyX

ASKER

thx everybody !