MySQL Forums
Forum List  »  Newbie

Re: Select sum(x) >0 with multiple columns
Posted by: Roland Bouman
Date: July 29, 2005 06:53AM

gaute wrote:
> Hi
>
> I am writing a script to show the average value of
> a question in a submitted survey form.

Well, than why use SUM(), you can use AVG()?

If your query does need te 0 score records for some other reason in the same query, you can immunize the AVG result by nulling the zeros:

SELECT AVG(CASE S1 WHEN 0 THEN NULL ELSE S1 END) -- ex using CASE
, AVG(IF (S1=0,NULL,S1) -- ex using IF
..
FROM evaluering

but if its alright to discard these records, youre almost in the right track:

WHERE 0 not in (S1,S2,S3...)

good luck!

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.