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

From: Rod Taylor <pg(at)rbt(dot)ca>
To: Greg Stark <gsstark(at)mit(dot)edu>
Cc: Josh Berkus <josh(at)agliodbs(dot)com>, 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 01:29:55
Message-ID: 1081560594.56361.818.camel@jester
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Fri, 2004-04-09 at 18:43, Greg Stark wrote:
> Josh Berkus <josh(at)agliodbs(dot)com> writes:
>
> > 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.
>
> If it's like Oracle's rownum then it's the row number of the *output*, not the
> position on disk. So it's not entirely blowing off the relational model any
> more than ORDER BY does.
>
> The weird thing is the number of cases where you want ORDER BY or rownum
> inside subselects. Which the solution to the original question needed.

It's not really like Oracles row num at all, though I suppose you can
emulate rownum using it. The intention is that you will use it for
"aggregates" like running totals, moving averages, counting, etc.

http://www.devx.com/getHelpOn/10MinuteSolution/16573/1954?pf=true

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Greg Sabino Mullane 2004-04-10 14:35:38 Re: SQL challenge--top 10 for each key value?
Previous Message Greg Sabino Mullane 2004-04-10 01:28:08 Re: Counting rows from two tables in one query