Simon Slavin <slav...@bigfraud.org> wrote:
> I have a setup which I will simplify as follows:
> 
> There is a table of courses.
> Every course can have any number of people working on it.
> Every course involves any number of tasks.
> 
> I want to make a SELECT which will return a table as follows:
> 
> course1 number-of-people-involved-in-course1 
> number-of-tasks-involved-in-course1
> course2 number-of-people-involved-in-course2 
> number-of-tasks-involved-in-course2
> course3 number-of-people-involved-in-course3 
> number-of-tasks-involved-in-course3
> course4 number-of-people-involved-in-course4 
> number-of-tasks-involved-in-course4

select name,
    (select count(*) from people where course=courses.id),
    (select count(*) from tasks where course=courses.id)
from courses;

-- 
Igor Tandetnik

_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to