前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >sqlzoo练习15-null-quiz

sqlzoo练习15-null-quiz

作者头像
皮大大
发布2021-03-01 10:09:11
2810
发布2021-03-01 10:09:11
举报
文章被收录于专栏:机器学习/数据可视化

sqlzoo练习15-NULL quiz

主要是对上节中学习到的NULL空值的理解与复习

NULL-quiz

练习

  1. select the code which uses an outer join correctly.
代码语言:javascript
复制
select teacher.name, dept.name
from teacher
left outer join dept on (teacher.dept=dept.id) -- 左连接
  1. Select the correct statement that shows the name of department which employs Cutflower -

选出雇佣了Cutfolowerl老师的系

代码语言:javascript
复制
select dept.name
from teacher
join dept on (dept.id=teacher.dept)
where teacher.name='Cutflower';
  1. Select out of following the code which uses a JOIN to show a list of all the departments and number of employed teachers

选出所有的院系和该院系雇佣的老师的数目

代码语言:javascript
复制
select dept.name, count(teacher.name)  -- 统计老师的个数
from teacher
right join dept on dept.id=teacher.dept
group by dept.name
  1. Using SELECT name, dept, COALESCE(dept, 0) AS result FROM teacher on teacher table will:
代码语言:javascript
复制
display 0 in result column for all teachers without department
  1. the result of Query

主要考察的是case语句的用法

代码语言:javascript
复制
select name,
     case when phone=2752 then 'two'
          when phone=2753 then 'three'
          when phone=2754 then 'four'
     end as digit
from teacher

  1. Select the result that would be obtained from the following code:
代码语言:javascript
复制
select name,
    case when dept in (1)
         then 'Computing'  -- 如果dept编号是1,则标记为computing;否则是Other
    else 'Other' end
from teacher;

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2020-1-31,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • sqlzoo练习15-NULL quiz
  • 练习
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档