Re: Help with simple query

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Collin Peters <cadiolis(at)gmail(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Help with simple query
Date: 2005-12-29 00:43:17
Message-ID: 2596.1135816997@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Collin Peters <cadiolis(at)gmail(dot)com> writes:
> Is there a nice simple query I can run that will return me a list of
> all the *latest* notes for all users (users can have many notes in the
> table)?

You can use SELECT DISTINCT ON for that, if you don't mind using a
Postgres-only feature. See the "weather reports" example in the SELECT
reference page.

If you want to stick to portable SQL, you can still do it, but it's
pretty ugly and slow. Look in the list archives for previous
discussions.

regards, tom lane

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message PFC 2005-12-29 01:31:50 Re: Help with simple query
Previous Message Frank Bax 2005-12-29 00:41:32 Re: Help with simple query