pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: elein <elein@varlena.com>
To: Josh Berkus <josh@agliodbs.com>
Cc: Rod Taylor <pg@rbt.ca>
Cc: Greg Stark <gsstark@mit.edu>
Cc: Jeff Boes <jboes@nexcerpt.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: SQL challenge--top 10 for each key value?
Date: Sat, 10 Apr 2004 16:46:51 -0700
Message-ID: <20040410164651.K409@cookie.varlena.com> (raw)
In-Reply-To: <200404090906.39541.josh@agliodbs.com>
References: <33af4fa4e4ec230574cefcff737ea40a@news.teranews.com>
	<87r7uyf3ki.fsf@stark.xeocode.com>
	<1081481466.56361.808.camel@jester>
	<200404090906.39541.josh@agliodbs.com>

Welcome to the real world, Josh.  There are people who
have full time salaried positions soley to attend 
standards meetings.

Note that ROW_NUMBER() really is handy, regardless of the
silly name.  And there was a little python function of mine 
that did it fairly simply, except that you needed to
initialize the counter in the connection before use.

create or replace function pycounter(integer)
returns integer as
'
   if args[0] == 0:
      SD["nextno"] = 1
      return SD["nextno"]
   try:
      SD["nextno"] += 1
   except:
      SD["nextno"] = 1
   return SD["nextno"]
' language 'plpythonu';

And clearly it can be done faster as a little
C function.

elein


On Fri, Apr 09, 2004 at 09:06:39AM -0700, Josh Berkus wrote:
> Rod,
> 
> > Something along the lines of the below would accomplish what you want
> > according to spec. ROW_NUMBER() is a spec defined function. (6.10 of
> > SQL200N)
> 
> Great leaping little gods!   They added something called "row number" to the 
> spec? 
> 
> Boy howdy, folks were right ... the ANSI committee really has completly blown 
> off the relational model completely.   First there was the addition of 
> network-database functions so that IBM could make DB2 look more like a real 
> database, now this ....
> 
> When a standards committee becomes hostage to a handful of vendors, kiss real 
> standards goodbye.
> 
> -- 
> Josh Berkus
> Aglio Database Solutions
> San Francisco
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 8: explain analyze is your friend



view thread (16+ messages)  latest in thread

Message-ID: <20040410164651.K409@cookie.varlena.com>
Permalink:  ../20040410164651.K409@cookie.varlena.com/
Also on:    postgresql.org/message-id/20040410164651.K409@cookie.varlena.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: elein@varlena.com, josh@agliodbs.com, pg@rbt.ca, gsstark@mit.edu, jboes@nexcerpt.com
  Subject: Re: SQL challenge--top 10 for each key value?
  In-Reply-To: <20040410164651.K409@cookie.varlena.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox