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 -> Re: not a GROUP BY expression

Re: not a GROUP BY expression

From: Zman <mz_161_at_yahoo.com>
Date: 9 Nov 2001 07:49:21 -0800
Message-ID: <39789f2d.0111090749.22eeb051@posting.google.com>


Try something like:

>SELECT choice, COUNT(choice), (COUNT(choice)/(SELECT COUNT(choice)
> FROM results
> WHERE pollid=1))*100
> FROM results
> WHERE pollid=1
> GROUP BY choice

select

       res.choice
,      count(res.choice)
,      ( count(res.choice) / tot.choices ) * 100  avg_choice
from
       ( select count(*) choices
         from results
         where pollid = 1 ) tot
,      results res
where 
       res.pollid = 1
group by
       res.choice, tot.choices

I've not tested this, but it should get you close. Received on Fri Nov 09 2001 - 09:49:21 CST

Original text of this message

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