0

Can i know why the divider is not showing value?

    select gg.columnA ,t.columnB, (gg.columnA / t.columnB) as C
    FROM #main t
LEFT OUTER JOIN #Total_ByGradeGender gg
    ON t.OrganizationCd = gg.OrganizationCd
    AND t.CountryCd = gg.CountryCd
    where t.organizationcd = '27849' 

The value for last column is always showing 0. Isn't should be columnA/12 ?

8   12  0
1   12  0
3   12  0

If i change the divider to an integer, then the value will show.

VeecoTech
  • 2,073
  • 8
  • 37
  • 49

1 Answers1

0

You need to cast to numeric

select gg.columnA ,t.columnB, (gg.columnA /cast( t.columnB as numeric))  as C
   FROM #main t
LEFT OUTER JOIN #Total_ByGradeGender gg
ON t.OrganizationCd = gg.OrganizationCd
AND t.CountryCd = gg.CountryCd
where t.organizationcd = '27849' 
M.S.
  • 4,283
  • 1
  • 19
  • 42