SQL Outer joins
Posted
by
dsquaredtech
on Stack Overflow
See other posts from Stack Overflow
or by dsquaredtech
Published on 2012-11-16T04:50:39Z
Indexed on
2012/11/16
5:00 UTC
Read the original article
Hit count: 147
Three tables courses,registration,students
columns in students
firstname,lastname,studentid,major,admitdate,graddate,gender,dob
columns in registration
courseid,studentid
columns in courses
coursenumber,coursename,credits
select statement I need to modify
select lastname as 'Last Name',sum(credits) as 'Credits Registered For' from students as s
inner join registration as r on s.studentid = r.studentid
inner join courses as c on c.coursenumber = c.courseid
group by last name;
the question on the lab is... Modify the previous query to show all students, even if they have not registered for a class. You should have 14 rows. Students who are not registered will show NULL in output.
I know this requires outer join of some sort but I'm not fully grasping these joins i've read multiple posts on here and other sites but can't seem figure it out.
© Stack Overflow or respective owner