Connecting Tech Pros Worldwide Forums | Help | Site Map

Working out a percentage using sql

Newbie
 
Join Date: Oct 2008
Posts: 1
#1: Oct 3 '08
I have a table that holds four questions and the values assigned to that question. The value can only be Yes or No.

The results will look something like this Q1) Y, Q2) N, Q3) Y, Q4) Y. How can I get my sql result to display 75%?

At the moment I can only get the count to say 3 Yes and 1 No.

Thank you in advance

ck9663's Avatar
Expert
 
Join Date: Jun 2007
Posts: 1,925
#2: Oct 3 '08

re: Working out a percentage using sql


What's the table structure?

-- CK
joedeene's Avatar
Site Addict
 
Join Date: Jul 2008
Location: US of A
Posts: 587
#3: Oct 4 '08

re: Working out a percentage using sql


Quote:

Originally Posted by tonyshort

I have a table that holds four questions and the values assigned to that question. The value can only be Yes or No.

The results will look something like this Q1) Y, Q2) N, Q3) Y, Q4) Y. How can I get my sql result to display 75%?

At the moment I can only get the count to say 3 Yes and 1 No.

Thank you in advance

would simple math not work, how is the "3 Yes and 1 No" returned, if you can add the Y's and N's then do something like divide the returned Y's by the total(Y+N) ? because 3/4 would give you .75, 75%...

joedeene
Reply