Re: Help with simple query - Mailing list pgsql-sql

From Tom Lane
Subject Re: Help with simple query
Date
Msg-id 2596.1135816997@sss.pgh.pa.us
Whole thread Raw
In response to Help with simple query  (Collin Peters <cadiolis@gmail.com>)
List pgsql-sql
Collin Peters <cadiolis@gmail.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


pgsql-sql by date:

Previous
From: Collin Peters
Date:
Subject: Help with simple query
Next
From: Frank Bax
Date:
Subject: Re: Help with simple query