Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> not a GROUP BY expression

not a GROUP BY expression

From: Chris Kilmer <kilmer_at_isomedia.com>
Date: 8 Nov 2001 14:53:30 -0800
Message-ID: <c7dc8506.0111081453.5a119ac3@posting.google.com>


I am trying to retrieve the results of a poll. I would like to display the choice, the number of votes the choice received and the percentage of the total votes the choice received. Here is the query:

SELECT choice, COUNT(choice), (COUNT(choice)/(SELECT COUNT(choice)

                                             FROM results
                                             WHERE pollid=1))*100
FROM results
WHERE pollid=1
GROUP BY choice                      

When I run the query, I get the following error:

SELECT choice, COUNT(choice), COUNT(choice)/(SELECT COUNT(*)

                                                    *
ERROR at line 1:
ORA-00979: not a GROUP BY expression

As you can see, the subquery is causing the problem. In the subquery, I'm trying to get the count of all the choices for the particular poll. I then want to divide the count of the current choice by the total number of choices. Any thoughts on how to get around this problem? Please respond to kilmer_at_isomedia.com as well as to the group. I sometimes have trouble with the newgroups. Thanks. Received on Thu Nov 08 2001 - 16:53:30 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US