Link to home
Start Free TrialLog in
Avatar of nriddock
nriddockFlag for United States of America

asked on

select ABS (SUM) question

i have a survey that dumps the results to a mysql database....fome time to time we will have anywhere from 12 responses to over 700+. the survey choices range from 1-6 with six being highest (1-6 = very dissatisifed - very satisfied)

one of the survey metrics is "give me % for all those answers 3 (satisfied) or higher" which in mysql translates to:

SELECT ABS( SUM( Q1 >3  )  /21  )...etc.

as i have the query right now it works great...the problem lies in the fact, as stated earlier...the number of responses varies each time and the "/21" of the query SELECT ABS( SUM( Q1 >3  )  /21  ) will change often....without having to go and rewrite the query each time...is there a way to use the COUNT feature in mysql to populate the "/XXX" part of the query?

thanks


full query
------------------------
SELECT ABS( SUM( Q1 >3  )  /21  ) , ABS( SUM( Q2 >3  )  /21  ) , ABS( SUM( Q4 >3  )  /21  ) ,ABS( SUM( Q5 >3  )  /21  ),ABS( SUM( Q6 >3  )  /21  ),ABS( SUM( Q6 >3  )  /21  )  
FROM metrics
ASKER CERTIFIED SOLUTION
Avatar of hernst42
hernst42
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of nriddock

ASKER

perfect...thanks for the quick response