math - Division in SQL Query always equals 0 -


this question has answer here:

basically have table on server mirror of table minus rows don't care about. i'm trying use number of rows , max id determine percentage of rows skipped when copying table.

i've never done math in sql query before, , it's simple i'm missing.

here query:

select  count(*) processed, max(id) - count(*) ignored, max(id) total, (max(id) - count(*)) / max(id) percentignored table 

here results

processed   ignored    total        percentignored 6213074     8462494    14675568     0 

if manually calculate 8462494/14675568 it's not zero. more 57%.

you can try below other casting float type pointed in linked post.

select max(id)*1.0 / (max(id) + count(*)) percentignored student 

Comments

Popular posts from this blog

javascript - Bootstrap Popover: iOS Safari strange behaviour -

Magento/PHP - Get phones on all members in a customer group -

session - Logging Out Using PHP -