From: | garry saddington <garry(at)schoolteachers(dot)co(dot)uk> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | simplifying SQL |
Date: | 2007-02-08 07:54:14 |
Message-ID: | 1170921254.10217.23.camel@localhost |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
I have this query which essentially returns records that exist in one
table (studentclass) and not another (effortandattainment) to check when
teachers have entered their student grades.
select
distinct(studentclass.studentclassid),classes.subject,studentclass.studentid as classstudent,classes.teacher,students.studentid,students.firstname,students.surname
from studentclass left join effortandattainment
on(effortandattainment.classid=studentclass.classid and
effortandattainment.studentid=studentclass.studentid),students,classes
where students.studentid=studentclass.studentid
and studentclass.classid=classes.classid
and studentclass.classid not in (
select studentclass.classid
from studentclass inner join effortandattainment
on(effortandattainment.classid=studentclass.classid and
effortandattainment.studentid=studentclass.studentid)
)
I was wondering whether a simpler method exists to do the same thing or
is this OK.
Regards
Garry
From | Date | Subject | |
---|---|---|---|
Next Message | Hannes Dorbath | 2007-02-08 07:54:53 | Re: DBI-Link 2.0 |
Previous Message | brian | 2007-02-08 07:40:07 | Re: 'greatest' function? |