reset password
Author Message
talisunep
Posts: 140
Posted 03:07 Nov 04, 2013 |

hi,

i was wondering isnt this query supposed to return 13 sections if we use the given table?
http://sun.calstatela.edu/~cysun/www/teaching/cs422/extras/university-create.sql

given query
http://sun.calstatela.edu/~cysun/www/teaching/cs422/extras/university-query.sql

-- 28. List the number courses offered by department.

select d.name as "Department Name", count(*) as "# of Courses Offered"
    from departments d, courses c
    where d.id = c.department_id
    group by d.name;

returns only 8 sections

i did a variation which returns 13 sections

select d.name as "Dept" , count(course_id) "No of Courses" from departments d
inner join courses c on c.department_id = d.id 
inner join sections s on s.course_id = c.id
group by d.name;

is this the req answer for --28?
 

Last edited by talisunep at 03:08 Nov 04, 2013.
talisunep
Posts: 140
Posted 03:19 Nov 04, 2013 |
talisunep wrote:

hi,

i was wondering isnt this query supposed to return 13 sections if we use the given table?
http://sun.calstatela.edu/~cysun/www/teaching/cs422/extras/university-create.sql

given query
http://sun.calstatela.edu/~cysun/www/teaching/cs422/extras/university-query.sql

-- 28. List the number courses offered by department.

select d.name as "Department Name", count(*) as "# of Courses Offered"
    from departments d, courses c
    where d.id = c.department_id
    group by d.name;

returns only 8 sections

i did a variation which returns 13 sections

select d.name as "Dept" , count(course_id) "No of Courses" from departments d
inner join courses c on c.department_id = d.id 
inner join sections s on s.course_id = c.id
group by d.name;

is this the req answer for --28?
 

im sorry the query on the website is correct for since its no of courses offered by dept and not the number of courses offered in the sections...

Last edited by talisunep at 03:34 Nov 04, 2013.