X-Original-To: pgsql-sql@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 26CDD476237 for ; Tue, 15 Apr 2003 14:59:50 -0400 (EDT) Received: from secure.tritus.ca (baxter.tritus.ca [209.47.166.15]) by postgresql.org (Postfix) with ESMTP id 5138C47610C for ; Tue, 15 Apr 2003 14:59:48 -0400 (EDT) Received: from [10.200.200.129] (CPE00045ae165bc-CM014320108734.cpe.net.cable.rogers.com [::ffff:24.157.7.10]) (AUTH: CRAM-MD5 adam@tritus.ca, TLS: TLSv1/SSLv3, 168bits, DES-CBC3-SHA) by secure.tritus.ca with esmtp; Tue, 15 Apr 2003 14:59:47 -0400 Date: Tue, 15 Apr 2003 14:59:32 -0400 From: Adam Sherman Cc: pgsql-sql@postgresql.org Subject: Re: Percentage of Total Occurances Message-ID: <30270000.1050433172@saturn> In-Reply-To: <1177.219.65.253.230.1050426637.squirrel@mail.trade-india.com> References: <6790000.1050418432@saturn> <1177.219.65.253.230.1050426637.squirrel@mail.trade-india.com> X-Mailer: Mulberry/3.0.3 (Linux/x86) X-OpenPGP: 82C7 7288 650F 8F77 2FFB C170 3698 125A 79C3 FC80 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline X-Spam-Status: No, hits=-32.5 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/238 X-Sequence-Number: 12939 On 04/15/03 22:40:37 +0530 mallah@trade-india.com wrote: >> I have a table being used for poll results: >> >> id >> poll_id >> question_id >> answer_id >> datestamp >> >> I what to figure out the percentage or respondants that gave each >> answer. This is based on occurance rather than values. > > select answer_id,count(*) from polls where poll_id = ? > group by answer_id ; > > gives number of response of each answer > > total_response = select count(*) from polls where poll_id = ? > > getting %age shud be trivial. > > Dunno if i missed your question . I'm looking to do everything in a single query. And get something like: answer_id -> percentage Thanks, A. -- Adam Sherman Tritus CG Inc. http://www.tritus.ca/ +1 (613) 797-6819