Database: coursera assignment 1
q.1: Find the titles of all movies directed by Steven Spielberg.
select title
from movie
where director = 'Steven Spielberg'
q.2: Find all years that have a movie that received a rating of 4 or 5, and sort them in increasing order.
select year
from movie, rating
where movie.mid = rating.mid and rating.stars >= 4
group by movie.mid
order by year
q.3: Find the titles of all movies that have no ratings.
select title
from movie, rating
where movie.mid not in (select rating.mid from rating)
group by movie.mid
q.4: Some reviewers didn't provide a date with their rating. Find the names of all reviewers who have ratings with a NULL value for the date.
select name
from reviewer re, rating ra
where re.rid = ra.rid and ra.ratingdate is null
q.5: Write a query to return the ratings data in a more readable format: reviewer name, movie title, stars, and ratingDate. Also, sort the data, first by reviewer name, then by movie title, and lastly by number of stars.
select name, title, stars, ratingdate
from movie, reviewer, rating
where movie.mid = rating.mid and reviewer.rid = rating.rid
order by name, title, stars
q.6: For all cases where the same reviewer rated the same movie twice and gave it a higher rating the second time, return the reviewer's name and the title of the movie.
select name, title
from movie, reviewer, rating r1, rating r2
where movie.mid = r1.mid and reviewer.rid = r1.rid and r1.mid = r2.mid and r1.rid = r2.rid and r1.stars < r2.stars and r1.ratingdate < r2.ratingdate
q.7: For each movie that has at least one rating, find the highest number of stars that movie received. Return the movie title and number of stars. Sort by movie title.
select title, max(stars)
from movie, rating
where movie.mid = rating.mid
group by rating.mid
order by title
q.8: For each movie, return the title and the 'rating spread', that is, the difference between highest and lowest ratings given to that movie. Sort by rating spread from highest to lowest, then by movie title.
select title, max(stars) - min(stars) as spread
from movie, rating
where movie.mid = rating.mid
group by rating.mid
order by spread desc, title
q.9: Find the difference between the average rating of movies released before 1980 and the average rating of movies released after 1980. (Make sure to calculate the average rating for each movie, then the average of those averages for movies before 1980 and movies after. Don't just calculate the overall average rating before and after 1980.)
Database: coursera assignment 1的更多相关文章
- JavaScript 编码小技巧
三元操作符 如果使用if...else语句,那么这是一个很好节省代码的方式. Longhand: const x = 20; let answer; if (x > 10) { answer = ...
- 19 个 JavaScript 编码小技巧
这篇文章适合任何一位基于JavaScript开发的开发者.我写这篇文章主要涉及JavaScript中一些简写的代码,帮助大家更好理解一些JavaScript的基础.希望这些代码能从不同的角度帮助你更好 ...
- 19个JavaScript简化编码小技巧
这篇文章适合任何一位基于JavaScript开发的开发者.我写这篇文章主要涉及JavaScript中一些简写的代码,帮助大家更好理解一些JavaScript的基础.希望这些代码能从不同的角度帮助你更好 ...
- 盘点Mysql的登陆方式
前置知识 我们想登陆到mysql中前提是肯定需要一个用户名和密码:比如 root root 在mysql中用户的信息会存放在 mysql数据库下的 user表中 可以 use mysql 然后sele ...
- 白日梦的MySQL专题(第33篇):各种登陆MySQL的骚操作
阅读原文 系列文章公众号首发,点击阅读原文 前置知识 我们想登陆到mysql中前提是肯定需要一个用户名和密码:比如 mysql -uroot -proot 在mysql中用户的信息会存放在 mysql ...
- Coursera Deep Learning 2 Improving Deep Neural Networks: Hyperparameter tuning, Regularization and Optimization - week1, Assignment(Gradient Checking)
声明:所有内容来自coursera,作为个人学习笔记记录在这里. Gradient Checking Welcome to the final assignment for this week! In ...
- Coursera Deep Learning 2 Improving Deep Neural Networks: Hyperparameter tuning, Regularization and Optimization - week1, Assignment(Initialization)
声明:所有内容来自coursera,作为个人学习笔记记录在这里. Initialization Welcome to the first assignment of "Improving D ...
- Coursera Deep Learning 2 Improving Deep Neural Networks: Hyperparameter tuning, Regularization and Optimization - week1, Assignment(Regularization)
声明:所有内容来自coursera,作为个人学习笔记记录在这里. Regularization Welcome to the second assignment of this week. Deep ...
- coursera普林斯顿算法课part1里Programming Assignment 2最后的extra challenge
先附上challenge要求: 博主最近在刷coursera普林斯顿大学算法课part1部分的作业,Programming Assignment2最后的这个extra challenge当初想了一段时 ...
随机推荐
- EasyMvc入门教程-入门
1.EasyMvc简介 EasyMvc主要是为了丰富asp.net core mvc控件而出现的: 它提倡简单,面向对象式开发,希望能快速开发的同时,仍然保持一定的灵活性. 2.EasyMvc初相识 ...
- LCD设备驱动程序
LCD是Liquid Crystal Display的简称,也就是经常所说的液晶显示器 LCD能够支持彩色图像的显示和视频的播放,是一种非常重要的输出设备 Framebuffer 是Linux系统 ...
- 【重点突破】——Drag&Drop拖动与释放
一.引言 在学习HTML5新特性的时候,学到了Drag&Drop这两种拖放API,这里根据拖动的是“源对象”还是“目标对象”做两个小练习,主要是为了理解与应用HTML5为拖放行为提供的7个事件 ...
- Ubuntu下的计划任务 -- cron的基本知识
下面不完全: 参考:http://blog.csdn.net/cuker919/article/details/6336457 cron是一个Linux下的后台进程,用来定期的执行一些任务.因为我用的 ...
- Solidworks如何生成爆炸图
1 自动爆炸 点击"爆炸视图"按钮,然后全部选中装配体(被选中的零件会变为蓝色,全部选中即全部变色)然后在组成偶尔的爆炸窗口中下拉,点击应用. 再点击完成 回到装配体面板, ...
- mysql rpm安装,以及修改charset
http://my.oschina.net/u/1156660/blog/343154?fromerr=tmDGGiDL 修改charset: http://stackoverflow.com/que ...
- vue2.0 watch 详解
vue官网解释: 一个对象,键是需要观察的表达式,值是对应回调函数.值也可以是方法名,或者包含选项的对象.Vue 实例将会在实例化时调用 $watch(),遍历 watch 对象的每一个属性. 也就是 ...
- C#遍历指定路径下的目录
通过指定路径訪问路径下的文件.在C#的开发中主要利用了Directory类和DirectoryInfo类,简要介绍Directory类中的成员:命名空间 System.IO 命名空间 1.Create ...
- gitbook 的资源同步到 github中(方便维护和备份)
进入SETTINGS -> Github -> Select a Repository. 到这一步为止,我们可以先去我们的github,创建一个仓库先,推荐同名.然后回来gitbook中, ...
- js错误: Unexpected number in JSON at position 2792 value里面有双引号怎么解决
源头 出现这个报错提示,大家从错误就可以看的出来,这就是json的错误,一般来说都是json格式出现了错误,本人遇到比较多的情况就是json字符串里面出现了一些会影响json格式的符号,这次出现这个 ...