From: Tom Lane <tgl@sss.pgh.pa.us>
To: A.M. <agentm@cmu.edu>
Cc: pgsql-sql@postgresql.org
Subject: Re: Getting the latest unique items
Date: Thu, 12 Dec 2002 02:13:29 -0500
Message-ID: <4081.1039677209@sss.pgh.pa.us> (raw)
In-Reply-To: <9352B184-0D90-11D7-BA9C-0030657192DA@cmu.edu>
References: <9352B184-0D90-11D7-BA9C-0030657192DA@cmu.edu>
"A.M." <agentm@cmu.edu> writes:
> When I try to run the following query:
> select distinct on(student_gradedmaterial.id) ...
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> ... order by submittime desc;
^^^^^^^^^^^^^^^^^^^
> I get the following error:
> ERROR: SELECT DISTINCT ON expressions must match initial ORDER BY
> expressions
Indeed. You might benefit from reading the DISTINCT ON usage example
given in the SELECT reference page,
http://www.ca.postgresql.org/users-lounge/docs/7.3/postgres/sql-select.html
(see under "Description"). Basically, DISTINCT ON is *only* useful when
designed hand-in-hand with an ORDER BY ...
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, agentm@cmu.edu
Subject: Re: Getting the latest unique items
In-Reply-To: <4081.1039677209@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