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

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 (view raw or flat)
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

pgsql-sql by date

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

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