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当初想了一段时 ...
随机推荐
- 解决官网下载jdk只有5k大小的错误
问题现象 官网 https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html 我选择linu ...
- 计算机视觉和模式识别领域SCI期刊介绍
原帖地址: http://blog.sciencenet.cn/blog-370458-750306.html 关于计算机视觉和模式识别领域的期刊并不是很多,下面我收集了一些该领域的代表性期刊,并介绍 ...
- linux下ftp、telnet的安装和使用
1.ftp的安装和使用 一般在各种linux的发行版中,默认带有的ftp软件是vsftp. 使用如下命令#rpm -qa | grep vsftpd可以检测出是否安装了vsftpd软件,如果没有安装, ...
- 2017.2.20 activiti实战--第五章--用户与组及部署管理(一)用户与组
学习资料:<Activiti实战> 第五章 用户与组及部署管理(一)用户与组 内容概览:讲解activiti中内置的一套用户.组的关系,以及如何通过API添加.删除.查询. 5.1 用户与 ...
- SQLServer-----SQLServer 2008 R2安装
- AutoCAD 样条曲线如何结束
如下所示,走了四个点之后曲线绘制结束想要闭合了 鼠标右击选择确认 然后变成下面这个样子,鼠标再右击就可以结束(然后又回从下面伸出来东西,还是右击)总之就是想要结束的时候:右击确认,不断右击 ...
- bigAutocomplete实现联想
直接举例说明: //xx联想 var list = $(".js-xxxx").text();//需要联想出的内容的list,该list由后台传入,保存在jsp页面,js取隐藏域值 ...
- Activity 事件以及如何得到新打开Activity关闭后返回的数据
1: package com.example.activity_basic; 2: 3: import android.os.Bundle; 4: import android.app.Activ ...
- 在MyEclipse上部署Tomcatserver
我在前面的博客中介绍了在Windows下安装Tomcatserver.这篇博客将介绍在MyEclipse上部署Tomcatserver 第一步:启动MyEclipse 第二步:选项Window-> ...
- Nginx配置SSL安全证书避免启动输入Enter PEM pass phrase
之前两篇文章已经很好的介绍了Nginx配置SSL的一些情况,配置好的Nginx每次启动都要 输两遍PEM pass phrase,很是不爽,尤其是在服务器重启后,Nginx压根就无法自动启动,必须手动 ...