sql server 2008 - Why does mathematical operation in SQL return 0 -


why calc value not calculated in tsql query below?

select     d1, d2, (d1+d2) 'sum', ((d1/(d1+d2))*100) calc     (select 3 d1, 6 d2) 

this result get:

d1          d2          sum         calc ----------- ----------- ----------- ----------- 3           6           9           0 

the integer division rounding zero
move 100. still rounding.
if cannot tolerate rounding don't use integers.

select     d1, d2, (d1+d2) 'sum', d1/(d1+d2) frac, (d1*100)/(d1+d2) pct     (select 3 d1, 6 d2) 

Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -