Division ( / ) not giving my answer in postgresql
I have a table software and columns in it as dev_cost , sell_cost . If dev_cost is 16000 and sell_cost is 7500. How do I find the quantity of software to be sold in order to recover the dev_cost ? I have queried as below: select dev_cost / sell_cost from software ; It is returning 2 as the answer. But we need to get 3, right? What would be the query for that? Thanks in advance. Ilmari Karonen Your columns have integer types, and integer division truncates the result towards zero . To get an accurate result, you'll need to cast at least one of the values to float or decimal : select cast(dev