MySQL Forums
Forum List  »  Newbie

Select sum(x) >0 with multiple columns
Posted by: gaute
Date: July 29, 2005 06:26AM

Hi

I am writing a script to show the average value of a question in a submitted survey form.

I have 14 questions, which can have the value 1-10, if the user submitts "I don't know" it returns the value 0.

When i calculate the average it includes the value 0 but still divides with all the submitted answers (see code).

How can i make a select statement which only includes values > 0?

Current select statement:

$select = "SELECT SUM(S1), SUM(S2), SUM(S3), SUM(S4), SUM(S5), SUM(S6)
, SUM(S7), SUM(S8), SUM(S9), SUM(S10), SUM(S11)
, SUM(S12), SUM(S13), SUM(S14)
FROM Evaluering";

I want it to do something like this :

$select = "SELECT SUM(S1), SUM(S2), SUM(S3), SUM(S4), SUM(S5), SUM(S6)
, SUM(S7), SUM(S8), SUM(S9), SUM(S10), SUM(S11)
, SUM(S12), SUM(S13), SUM(S14)
WHERE S1,S2,S3,S4,S5,S6,S7,S8,S9,S10,S11,S12,S13,S14 > 0
FROM Evaluering";

Any suggestions?

Options: ReplyQuote




Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.