2

I need to change my query to return only 2 decimal points

SELECT (AVG(cost)) AS 'Average Cost $'
FROM donuts
WHERE cost;

I don't want to use the ROUND function because I wont get a decimal.

SELECT ROUND(AVG(cost)) AS 'Average Cost $'
FROM donuts
WHERE cost;

Any Suggestions,

User051593
  • 61
  • 1
  • 1
  • 14

1 Answers1

5

You will get decimal point with the mysql round() function. You have to pass number of decimal points you wish to display. Default value is 0.

For example, in order to get 2 decimal points you will run this query:

SELECT ROUND(AVG(cost), 2) AS 'Average Cost $'
FROM donuts
WHERE cost > 0;

http://dev.mysql.com/doc/refman/5.0/en/mathematical-functions.html#function_round

Boris
  • 2,275
  • 20
  • 21