x

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.

more ▼

asked May 21, 2012 at 03:09 PM in Default

avatar image

n3w2sql
870 22 32 39

(comments are locked)
10|1200 characters needed characters left

2 answers: sort voted first

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

more ▼

answered May 21, 2012 at 03:23 PM

avatar image

Kev Riley ♦♦
64k 48 61 81

(comments are locked)
10|1200 characters needed characters left

Thanks :), I had to convert it so it now shows as 0.48

more ▼

answered May 21, 2012 at 03:44 PM

avatar image

n3w2sql
870 22 32 39

(comments are locked)
10|1200 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

SQL Server Central

Need long-form SQL discussion? SQLserverCentral.com is the place.

Topics:

x2076

asked: May 21, 2012 at 03:09 PM

Seen: 489 times

Last Updated: May 21, 2012 at 03:44 PM

Copyright 2016 Redgate Software. Privacy Policy