开发者

How to get column value without decimal in MYSQL

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开发者_StackOverflow中文版 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


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


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.


http://dev.mysql.com/doc/refman/5.0/en/precision-math-rounding.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜