Untitled

mail@pastecode.io avatar
unknown
pgsql
a year ago
916 B
2
Indexable
Never
/*q1*/
select * from students;

/*q2*/

select * from students;

/*q3*/

select * from students
where contact_info notnull;

/*q4*/

select s.*,m.name
from students s
left join majors m
 on s.students_majors
= m.majors_id;

/*q5*/

select s.*,m.name
from students s
full outer join majors m on m.majors_id = s.students_majors;

/*q6*/


select
    s.students_id ,s.first_name,s.last_name,count(sc."courses_id@") coursescounter,sum(c.units) from students s
 left join students_courses sc
     on s.students_id = sc."students_id@"
 left join courses c on sc."courses_id@" = c.courses_id
group by s.last_name, s.first_name, s.students_id;

/*q7*/

select
c.name,c.units,count(sc."students_id@") studentscounter from courses c
left join students_courses sc
 on c.courses_id = sc."courses_id@"
left join students s on sc."courses_id@" = s.students_id
group by c.units, c.name;