Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions 8_using_null.sql
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ SELECT name, COALESCE(mobile, '07986 444 2266')
-- # 6. Use the COALESCE function and a LEFT JOIN to print the name and
-- #department name. Use the string 'None' where there is no
-- #department.
SELECT name, COALESCE(dept, 'None')
FROM teacher;
SELECT teacher.name, COALESCE(dept.name,'None')
FROM teacher LEFT JOIN dept
ON teacher.dept=dept.id

-- # 7. Use COUNT to show the number of teachers and the number of
-- #mobile phones.
Expand Down Expand Up @@ -62,4 +63,4 @@ SELECT teacher.name,
THEN 'Art'
ELSE 'None'
END
FROM teacher;
FROM teacher;