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

From: Greg Stark <gsstark(at)mit(dot)edu>
To: elein <elein(at)varlena(dot)com>
Cc: Josh Berkus <josh(at)agliodbs(dot)com>, 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-11 04:38:20
Message-ID: 871xmvf7sz.fsf@stark.xeocode.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql


elein <elein(at)varlena(dot)com> writes:

> 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.

Does this approach have a hope of working if it's used twice in the same
query?

--
greg

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Dennis 2004-04-11 04:59:50 cursors and for loops?
Previous Message elein 2004-04-11 01:54:35 Re: SQL challenge--top 10 for each key value?