Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 002D76309F0 for ; Thu, 22 Jul 2010 10:18:20 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 79441-08 for ; Thu, 22 Jul 2010 13:18:11 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from jupiter.marktest.pt (delta.marktest.pt [80.251.174.116]) by mail.postgresql.org (Postfix) with ESMTP id 4637E62DBEC for ; Thu, 22 Jul 2010 10:18:12 -0300 (ADT) Received: from Proteu (proteu.marktest.pt [10.61.90.54]) by jupiter.marktest.pt with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2653.13) id PBK1JQSV; Thu, 22 Jul 2010 14:18:09 +0100 Message-ID: <6FDFC090436D4DA98EBB99D0757B5930@marktestcr.marktest.pt> From: "Oliveiros d'Azevedo Cristina" To: , "Rainer Stengele" References: Subject: Re: grouping subsets Date: Thu, 22 Jul 2010 14:18:09 +0100 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="ISO-8859-15"; reply-type=original Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.5512 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=1.229 tagged_above=-5 required=5 tests=BAYES_50=0.8, STOX_REPLY_TYPE=0.439, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: * X-Archive-Number: 201007/93 X-Sequence-Number: 34406 Howdy, Rainer. Please advice me, The dates always follow that sequential pattern? Or can be holes on the dates sequence? Best, Oliveiros ----- Original Message ----- From: "Rainer Stengele" To: Sent: Thursday, July 22, 2010 9:09 AM Subject: [SQL] grouping subsets > 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 > > > > > > -- > Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) > To make changes to your subscription: > http://www.postgresql.org/mailpref/pgsql-sql