Reputation: 1539
I'm trying to get integer value with ABS and AVG functions in MySQL but it's still giving me float value.
select ABS(AVG(quantity)) as average from stocks
This query should return absolute integer value but it's return float value like 125.889
. What's the matter ?
Upvotes: 0
Views: 1440
Reputation: 115600
ABS()
stands for absolute, it doesn't return integer necessarily.
You'll have to use one of the mathematical functions like FLOOR()
, CEILING()
, ROUND()
, TRUNCATE( ,0)
or cast the result to INTEGER
.
Upvotes: 4