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