Re: Some insight on the proper SQL would be appreciated

From: Harald Fuchs <hari(dot)fuchs(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Some insight on the proper SQL would be appreciated
Date: 2010-06-09 12:32:21
Message-ID: puk4q875ey.fsf@srv.protecting.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

In article <4C0F4BA8(dot)3040805(at)gmail(dot)com>,
Ognjen Blagojevic <ognjen(dot)d(dot)blagojevic(at)gmail(dot)com> writes:

> Plenty of solutions here:
> http://www.xaprb.com/blog/2006/12/07/how-to-select-the-firstleastmax-row-per-group-in-sql/

This doesn't mention the incredibly powerful windowing functions of
PostgreSQL >= 8.4.0:

SELECT username, firstname, lastname, signedup
FROM (
SELECT username, firstname, lastname, signedup,
row_number() OVER (PARTITION BY username ORDER BY signedup)
FROM mytbl
) dummy
WHERE row_number <= 5

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Bill Moran 2010-06-09 12:53:34 Locale, LL_COLLATE and sorting case-insensatively
Previous Message Massa, Harald Armin 2010-06-09 11:38:40 Windows: Compiling and linking dynamically-loaded functions