question

n3w2sql avatar image
n3w2sql asked

Percentages

Hi I am trying to do a percentage calculation and I dont know how to get it to work in sql. I am trying to get a success% ie [Total In] 91, [on time] 44, Late 47, [Success] answer would be 48%. can anyone tell me how to do this calculation? If anyone knows how to do this I would be very grateful.
sql-server-2008
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Kev Riley avatar image
Kev Riley answered
Try this. If the fields are integers you will need to convert [on time] to a decimal, otherwise you will be doing integer divsion select ([on time] * 1.0) / [Total In] as Success that will give 0.48
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

n3w2sql avatar image
n3w2sql answered
Thanks :), I had to convert it so it now shows as 0.48
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.