From: Tom Lane <tgl@sss.pgh.pa.us>
To: Collin Peters <cadiolis@gmail.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: Help with simple query
Date: Wed, 28 Dec 2005 19:43:17 -0500
Message-ID: <2596.1135816997@sss.pgh.pa.us> (raw)
In-Reply-To: <df01c91b0512281558h3b760e89v80b4354e99183e99@mail.gmail.com>
References: <df01c91b0512281558h3b760e89v80b4354e99183e99@mail.gmail.com>
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: tgl@sss.pgh.pa.us, cadiolis@gmail.com
Subject: Re: Help with simple query
In-Reply-To: <2596.1135816997@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox