Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 7DE48632806 for ; Thu, 22 Jul 2010 10:25:43 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 65247-02 for ; Thu, 22 Jul 2010 13:25:34 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail.diplan.de (ns.diplan.de [212.34.188.4]) by mail.postgresql.org (Postfix) with ESMTP id 1BD046349AE for ; Thu, 22 Jul 2010 10:25:36 -0300 (ADT) Received: from [192.168.99.164] (stengelepc.diplan.de [192.168.99.164]) by mail.diplan.de (Postfix outbound) with ESMTP id 768023B7413; Thu, 22 Jul 2010 15:25:34 +0200 (CEST) Message-ID: <4C4846CE.4070701@diplan.de> Date: Thu, 22 Jul 2010 15:25:34 +0200 From: Rainer Stengele Organization: diplan GmbH 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 MIME-Version: 1.0 To: Oliveiros d'Azevedo Cristina CC: pgsql-sql@postgresql.org Subject: Re: grouping subsets References: <6FDFC090436D4DA98EBB99D0757B5930@marktestcr.marktest.pt> In-Reply-To: <6FDFC090436D4DA98EBB99D0757B5930@marktestcr.marktest.pt> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 8bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.79 tagged_above=-5 required=5 tests=BAYES_50=0.8, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201007/94 X-Sequence-Number: 34407 Hi Oliveiros, yes, the date is always incremented - but anyway the date column is not really the point! Actually the first tow columns are relevant. I want them gouped together as indicated, adding up column 1 in the blocks with identical second column, but not adding up over all the rows. Hope I could express it! Mit freundlichen Grüßen / Best Regards Rainer Stengele __|___ | Dipl. Inf. (Univ.) Rainer Stengele | Technical Control - System Administration | | email : Rainer.Stengele@diplan.de | voice/fax: ++49-9131-7778-85/88 | WWW : http://www.diplan.de | | diplan GmbH | Wetterkreuz 27 | 91058 Erlangen, Germany Diese E-Mail kann vertrauliche und/oder rechtlich geschützte Informationen enthalten. Wenn Sie nicht der richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren Sie bitte den Absender und vernichten Sie diese Mail. Das unerlaubte Kopieren sowie die unbefugte Weitergabe dieser Mail ist nicht gestattet. This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden. Am 22.07.2010 15:18, schrieb Oliveiros d'Azevedo Cristina: > 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 > >