Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 0326E632857 for ; Thu, 22 Jul 2010 05:45:17 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 38486-06 for ; Thu, 22 Jul 2010 08:45:09 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from lo.gmane.org (lo.gmane.org [80.91.229.12]) by mail.postgresql.org (Postfix) with ESMTP id 6BBC7632663 for ; Thu, 22 Jul 2010 05:45:09 -0300 (ADT) Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1ObrOq-0003ts-LJ for pgsql-sql@postgresql.org; Thu, 22 Jul 2010 10:45:04 +0200 Received: from 212.34.176.74 ([212.34.176.74]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 22 Jul 2010 10:45:04 +0200 Received: from rainer.stengele by 212.34.176.74 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 22 Jul 2010 10:45:04 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: pgsql-sql@postgresql.org From: Rainer Stengele Subject: grouping subsets Date: Thu, 22 Jul 2010 10:09:16 +0200 Lines: 38 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: 212.34.176.74 User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.8.1.17) Gecko/20080914 Lightning/0.8 Thunderbird/2.0.0.17 Mnenhy/0.7.5.666 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=1.954 tagged_above=-5 required=5 tests=BAYES_50=0.8, RCVD_NUMERIC_HELO=1.164, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: * X-Archive-Number: 201007/89 X-Sequence-Number: 34402 Hi, having a table similar to | 1 | B | [2010-07-15 Do] | | 1 | B | [2010-07-16 Fr] | |---+---+-----------------| | 2 | C | [2010-07-17 Sa] | | 2 | C | [2010-07-18 So] | |---+---+-----------------| | 1 | B | [2010-07-19 Mo] | | 1 | B | [2010-07-20 Di] | | 1 | B | [2010-07-21 Mi] | | 1 | B | [2010-07-22 Do] | |---+---+-----------------| | 3 | D | [2010-07-23 Fr] | a simple group by gives me: | 6 | B | | 4 | C | | 3 | D | What I want to get is the values grouped by "subset", where a subset is a set of rows with identical column until the colum changes. Is there a way to get | 2 | B | | 4 | C | | 4 | B | | 3 | D | by SQL only? - Rainer