Skip site navigation (1) Skip section navigation (2)

Re: SQL challenge--top 10 for each key value?

From: elein <elein(at)varlena(dot)com>
To: Josh Berkus <josh(at)agliodbs(dot)com>
Cc: Rod Taylor <pg(at)rbt(dot)ca>, Greg Stark <gsstark(at)mit(dot)edu>,Jeff Boes <jboes(at)nexcerpt(dot)com>, pgsql-sql(at)postgresql(dot)org
Subject: Re: SQL challenge--top 10 for each key value?
Date: 2004-04-10 23:46:51
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-sql
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"]
      SD["nextno"] += 1
      SD["nextno"] = 1
   return SD["nextno"]
' language 'plpythonu';

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


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

In response to


pgsql-sql by date

Next:From: eleinDate: 2004-04-11 01:54:35
Subject: Re: SQL challenge--top 10 for each key value?
Previous:From: Yasir MalikDate: 2004-04-10 22:19:48
Subject: Re: begin update ... syntax error

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group