From: Tomasz Myrta <jasiek@klaster.net>
To: A.M. <agentm@cmu.edu>
Cc: pgsql-sql@postgresql.org
Subject: Re: Getting the latest unique items
Date: Thu, 12 Dec 2002 09:34:53 +0100
Message-ID: <3DF84A2D.80004@klaster.net> (raw)
In-Reply-To: <9352B184-0D90-11D7-BA9C-0030657192DA@cmu.edu>
References: <9352B184-0D90-11D7-BA9C-0030657192DA@cmu.edu>
A.M. wrote:
> When I try to run the following query:
>
> select distinct on(student_gradedmaterial.id) student_gradedmaterial.id
> from coursesection_student,student_gradedmaterial WHERE
> gradedmaterialid=1 AND
> coursesection_student.studentid=student_gradedmaterial.studentid AND
> coursesectionid=1 and score is not null order by submittime desc;
>
> I get the following error:
>
> ERROR: SELECT DISTINCT ON expressions must match initial ORDER BY
> expressions
No
You have to change your sort order (as in error above). It should be:
order by student_gradematerial.id asc, submittime desc;
Tomasz Myrta
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: jasiek@klaster.net, agentm@cmu.edu
Subject: Re: Getting the latest unique items
In-Reply-To: <3DF84A2D.80004@klaster.net>
* 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