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

Re: fetch first rows of grouped data

From: "D'Arcy J(dot)M(dot) Cain" <darcy(at)druid(dot)net>
To: Claudia Kosny <ckosny(at)gmx(dot)net>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: fetch first rows of grouped data
Date: 2007-08-27 16:51:02
Message-ID: 20070827125102.e52b43de.darcy@druid.net (view raw or flat)
Thread:
Lists: pgsql-sql
On Mon, 27 Aug 2007 18:36:47 +0200
Claudia Kosny <ckosny(at)gmx(dot)net> wrote:
> I have a list of events that take place in a certain city at a certain 
> date. Now I would like to have the first two (ordered by date) events 
> for each city.
> 
> Is there a way to do this with one query?
> I am using PostgreSQL 7.4.

I believe you are looking for the LIMIT keyword.  Check the docs on the
web site.

-- 
D'Arcy J.M. Cain <darcy(at)druid(dot)net>         |  Democracy is three wolves
http://www.druid.net/darcy/                |  and a sheep voting on
+1 416 425 1212     (DoD#0082)    (eNTP)   |  what's for dinner.

In response to

Responses

pgsql-sql by date

Next:From: Joel RichardDate: 2007-08-27 17:34:09
Subject: Re: fetch first rows of grouped data
Previous:From: Claudia KosnyDate: 2007-08-27 16:36:47
Subject: fetch first rows of grouped data

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