X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id A47A9D7F67 for ; Thu, 25 Aug 2005 09:31:20 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 63961-05 for ; Thu, 25 Aug 2005 12:31:15 +0000 (GMT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by svr1.postgresql.org (Postfix) with ESMTP id 11343D7F6A for ; Thu, 25 Aug 2005 09:31:15 -0300 (ADT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by news.hub.org (8.13.1/8.13.1) with ESMTP id j7PCVExb066157 for ; Thu, 25 Aug 2005 12:31:14 GMT (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.13.1/8.13.1/Submit) id j7PCKWsj063965 for pgsql-admin@postgresql.org; Thu, 25 Aug 2005 12:20:32 GMT (envelope-from news) From: Lars Haugseth X-Newsgroups: pgsql.admin Subject: Re: How this query! Date: Thu, 25 Aug 2005 14:21:20 +0200 Organization: I could tell you, but then I'd have to kill you. Lines: 26 Message-ID: <87pss2qkan.fsf@skapulf.larshaugseth.com> References: <62683.202.152.170.186.1124970240.squirrel@202.152.170.186> Reply-To: Lars Haugseth Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Complaints-To: usenet@news.hub.org Cc: richard@orbisindonesia.com User-Agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (gnu/linux) Cancel-Lock: sha1:9wsmjyzVQGhIiwXRDTHzP6Kf1/E= To: pgsql-admin@postgresql.org X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=-2.82 required=5 tests=[ALL_TRUSTED=-2.82] X-Spam-Level: X-Archive-Number: 200508/311 X-Sequence-Number: 18630 * richard@orbisindonesia.com ("Richard Susanto") wrote: | | Folks, | would you like help me how to query this case. | | I have tbl_a, the fields are : | item_record | item_product_name | item_qty | | | if the data are : | | item_record = 1,2,3,4,5,6 | item_product_name = a,b,a,c,d,c,... | item_qty = 10,5,15,10,20,5,... | | How the query to sum item_qty_total if i want the result : | item_product_name = a,b,c,d | item_qty_total = 25,5,15,20 SELECT item_product_name, sum(item_qty) FROM tbl_a GROUP BY item_product_name; -- Lars Haugseth