Divide Operator

https://app.dataquest.io/m/257/guided-project%3A-analyzing-cia-factbook-data-using-sql/7/next-steps

%%sql
select 
    name,
    area_land,
    area_water,
    (area_water/area_land) as land_water 
from facts
where 
    area_water > 0 
limit 1

I expected to get land_water ratio, in this case: 0.049

Instead of this I received a 0.

if instead of dividing one field by another divided by an integer the division operator works correctly, so I have also tried to do a “cast” at int of both fields in case they come in a different format than a number, but it hasn’t worked

Thanks you all

When you said you tried to do a cast, did you try this?:

(CAST(area_water AS FLOAT)/CAST(area_land AS FLOAT)) as land_water

This gave me the desired land/water ratio.

name area_land area_water land_water
0 Albania 27398 1350 0.049274

Hello!

I’m not sure what I was putting wrong, but with your ruling it works just fine,

thank you.