sql - How to CAST to decimal without rounding in TSQL -


using sql statement:

select count(distinct[user].id) usertablecount,  count(qa.requestid) qacount,  qa.assignedtouser,  cast((count(qa.requestid)/count(distinct [user].id)) decimal(10,4)) percentof  [user]   join [qa] on [user].id = [qa].requestid  qastatus = 'pink' group [qa].assignedtouser 

i these results: enter image description here

how 2 decimal space result isn't rounded?

sql performing division using integer datatypes. multiply 1 of inputs using division 1.00.

ex.

cast(((count(qa.requestid)*1.00)/count(distinct [user].id)) decimal(10,2)) 

in situation:

cast((count(qa.requestid)/count(distinct [user].id)) decimal(10,4)) 

the result not hope receive because integer division performed before cast operation.


Comments

Popular posts from this blog

What is happening when Matlab is starting a "parallel pool"? -

angular - DownloadURL return null in below code -

php - Cannot override Laravel Spark authentication with own implementation -