Search Postgresql Archives

Re: Some insight on the proper SQL would be appreciated

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



In article <4C0F4BA8.3040805@xxxxxxxxx>,
Ognjen Blagojevic <ognjen.d.blagojevic@xxxxxxxxx> 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


-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux