SQL: Only Rounded numbers shown, everything else: Useless -
i'm having terrible problems sql, trying calculate values, similiar ex. below:
select sum(ordersachieved)/ sum(saleopportunities) calculatedvalue ( select count(ot.salesopportunity) saleopportunities count(vk.orders) ordersachieved fact_vertriebkalkulation vk )
sadly every number takes place in calculation, shown last rounded number! say: 3/4 gives me 0, , 4/4 = 1, 8/4 = 2, , on. while trying find out problem be, found following seems same thing!
select 2/7 value
gives out = 0!!! tried this
select convert(float,2/7) value
and it's same thing! can do, has ever seen this? or know answer question? lot in advance
select 2/7 value
...using 2 integers means integer division, correct 0.
select 2.0/7 value
...using @ least 1 floating point type gives 0.285714 seem looking for.
in other words, cast either of operands float, , division give result want;
select convert(float,2)/7 value
if cast after division done integer division, you'll casting resulting 0.
Comments
Post a Comment