问题
I have two column in my mysql table A and B and I am fetching records like this:
select (A/B) from table
But problem is that Above query providing vales something like this:
12.00
3.4
78.9
But I want to get result like this:
12
3
78
Which MySQL function I will use for this ??
Thanks
回答1:
If you want 78.9 to be 78 then
SELECT Floor(A/B) FROM table
If you want 78.9 to be 79 then
SELECT Ceiling(A/B) FROM table
回答2:
Just ROUND your result:
SELECT ROUND(A/B, 0) FROM table
You can also combine ROUND with FLOOR if you always want to round down.
回答3:
http://dev.mysql.com/doc/refman/5.0/en/precision-math-rounding.html
来源:https://stackoverflow.com/questions/5660199/how-to-get-column-value-without-decimal-in-mysql