Skip to content Skip to sidebar Skip to footer

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 query providing vales something like this: 12.0

Solution 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

Solution 2:

Just ROUND your result:

SELECT ROUND(A/B, 0) FROMtable

You can also combine ROUND with FLOOR if you always want to round down.

Solution 3:

Post a Comment for "How To Get Column Value Without Decimal In Mysql"