X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 2385F535CF for ; Mon, 4 Apr 2005 11:16:52 +0100 (BST) 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 53717-01 for ; Mon, 4 Apr 2005 10:16:48 +0000 (GMT) Received: from mail2.itxmarket.com (fw.itxmarket.com [213.11.40.109]) by svr1.postgresql.org (Postfix) with ESMTP id CE2705372D for ; Mon, 4 Apr 2005 11:16:46 +0100 (BST) Received: from icommerce.fr (mich2.itxmarket.com [192.168.2.26]) by mail2.itxmarket.com (Postfix) with ESMTP id 0F4B837C18 for ; Mon, 4 Apr 2005 12:16:48 +0200 (CEST) Received: by icommerce.fr (Postfix, from userid 1001) id F2C0922825; Mon, 4 Apr 2005 12:16:47 +0200 (CEST) Date: Mon, 4 Apr 2005 12:16:47 +0200 From: "Michael L. Hostbaek" To: pgsql-sql@postgresql.org Subject: select & group by Message-ID: <20050404101647.GJ23648@mich2.itxmarket.com> Mail-Followup-To: "Michael L. Hostbaek" , pgsql-sql@postgresql.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Operating-System: FreeBSD 5.3-STABLE i386 X-PGP-Key: http://www.freebsdcluster.org/~mich/ User-Agent: Mutt/1.5.9i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.05 tagged_above=0 required=5 tests=FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200504/40 X-Sequence-Number: 20933 I've got a problem selecting some specific data from my table. Imagine the following rows: part | mfg | qty | price | eta --------------------------------------- TEST1 ABC 10 100 (No ETA, as item is in stock) TEST1 ABC 12 120 04/04 TEST2 CBA 17 10 05/05 TEST2 CBA 10 20 (No ETA, as item is in stock) I'd like my selection to produce the following result: part | mfg | qty | qty incoming | highest price | eta ------------------------------------------------------------- TEST1 ABC 10 12 120 04/04 TEST2 CBA 10 17 20 05/05 Any clues on how to do this ? I kow the group by part, mfg, max(price) - but I do not know how to deal with the splitting up qty and stock qty and incoming qty. Thanks. /mich