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 6FA4256A3F for ; Thu, 17 Mar 2005 21:33:07 +0000 (GMT) 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 86185-03 for ; Thu, 17 Mar 2005 21:32:56 +0000 (GMT) Received: from rproxy.gmail.com (rproxy.gmail.com [64.233.170.201]) by svr1.postgresql.org (Postfix) with ESMTP id 2F76156A54 for ; Thu, 17 Mar 2005 21:32:30 +0000 (GMT) Received: by rproxy.gmail.com with SMTP id j1so673466rnf for ; Thu, 17 Mar 2005 13:32:32 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:references; b=LDlHlVl6WuvN0yVw8ASnZ5LiBJeCBn6SIv4PjrgkoeZ2L2NEw53/DZK1aseYveJu+3JDGlXGKKDbUFTcb4MBzO9y+ELdkur5GaJpyZR+v1rsrgn/Lu7BElyHw5WgimN8CED/Z7zkGL++wEemGim8ejirsqL9VEVOazDfGrOxaNg= Received: by 10.38.15.17 with SMTP id 17mr2057302rno; Thu, 17 Mar 2005 13:32:31 -0800 (PST) Received: by 10.38.97.29 with HTTP; Thu, 17 Mar 2005 13:32:31 -0800 (PST) Message-ID: Date: Thu, 17 Mar 2005 16:32:31 -0500 From: Jaime Casanova Reply-To: Jaime Casanova To: Leon Stringer Subject: Re: Consecutive row count query Cc: pgsql-sql@postgresql.org In-Reply-To: <1111090884.22783.5.camel@localhost.localdomain> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit References: <1111090884.22783.5.camel@localhost.localdomain> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.26 tagged_above=0 required=5 tests=AWL, DNS_FROM_RFC_ABUSE, RCVD_BY_IP X-Spam-Level: X-Archive-Number: 200503/249 X-Sequence-Number: 20728 On Thu, 17 Mar 2005 20:21:24 +0000, Leon Stringer wrote: > Hi, > > I wondered if anyone could answer the following question: > > If I have a table such as the one below: > > col1 col_order > ----------- > Apple 1 > Apple 2 > Orange 3 > Banana 4 > Apple 5 > > Is there a way I can get the following results: > > Apple 2 > Orange 1 > Banana 1 > Apple 1 > A function? regards, Jaime Casanova