题目链接:https://sqlzoo.net/wiki/Using_Null
题目 1select name from teacher
where dept is null;
2
select a.name,b.name from teacher a
inner join dept b on a.dept=b.id;
3
select a.name,b.name from teacher a
left join dept b on a.dept=b.id;
4
select a.name,b.name from teacher a
right join dept b on a.dept=b.id;
5
select name,coalesce(mobile,'07986 444 2266') from teacher
6
select a.name,coalesce(b.name,'None') from teacher a
left join dept b on a.dept = b.id;
7
select count(name),count(mobile) from teacher;
8
select b.name,count(a.name) from teacher a
right join dept b on b.id=a.dept
group by b.name;
9
select a.name,case
when b.id=1 then 'Sci'
when b.id=2 then 'Sci'
else 'Art' end
from teacher a left join dept b
on a.dept=b.id;
10
select a.name,case
when b.id=1 then 'Sci'
when b.id=2 then 'Sci'
when b.id=3 then 'Art'
else 'None' end
from teacher a left join dept b
on a.dept=b.id;
网友评论