欢迎来到淘文阁 - 分享文档赚钱的网站! | 帮助中心 好文档才是您的得力助手!
淘文阁 - 分享文档赚钱的网站
全部分类
  • 研究报告>
  • 管理文献>
  • 标准材料>
  • 技术资料>
  • 教育专区>
  • 应用文书>
  • 生活休闲>
  • 考试试题>
  • pptx模板>
  • 工商注册>
  • 期刊短文>
  • 图片设计>
  • ImageVerifierCode 换一换

    数据库sql习题及答案.pdf

    • 资源ID:77852869       资源大小:92.86KB        全文页数:5页
    • 资源格式: PDF        下载积分:5金币
    快捷下载 游客一键下载
    会员登录下载
    微信登录下载
    三方登录下载: 微信开放平台登录   QQ登录  
    二维码
    微信扫一扫登录
    下载资源需要5金币
    邮箱/手机:
    温馨提示:
    快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。
    如填写123,账号就是123,密码也是123。
    支付方式: 支付宝    微信支付   
    验证码:   换一换

     
    账号:
    密码:
    验证码:   换一换
      忘记密码?
        
    友情提示
    2、PDF文件下载后,可能会被浏览器默认打开,此种情况可以点击浏览器菜单,保存网页到桌面,就可以正常下载了。
    3、本站不支持迅雷下载,请使用电脑自带的IE浏览器,或者360浏览器、谷歌浏览器下载即可。
    4、本站资源下载后的文档和图纸-无水印,预览文档经过压缩,下载后原文更清晰。
    5、试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。

    数据库sql习题及答案.pdf

    文档/*Question 1:Find the titles of all movies directed by Steven Spielberg.select title from movie where director=Steven Spielberg Question 2:Find all years that have a movie that received a rating of 4 or 5,and sort them in increasing order.select distinct year from movie,rating where movie.mid=rating.mid and stars in(4,5)order by year Question 3:Find the titles of all movies that have no ratings select title from movie where mID in (select mid from Movie except select mid from rating )select title from movie except select title from movie,rating where movie.mid=rating.mid Question 4:Some reviewers didnt 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,rating where reviewer.rid=rating.rid and ratingdate is null Question 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,rating,reviewer 文档 where movie.mid=rating.mid and reviewer.rid=rating.rid order by name,title,stars Question 6:For all cases where the same reviewer rated the same movie twice and gave it a higher rating the second time,return the reviewers name and the title of the movie.select name,title from rating as F,Rating as S,Movie,Reviewer where F.rID=S.rID and F.mID=S.mID and F.starsS.stars and F.ratingDater2.ratingdate and r1.starsr2.stars)as r where movie.mid=r.mid and reviewer.rid=r.rid Question 7:For each movie,find the highest number of stars that movie received as a rating.Return the movie title and number of stars.Sort by movie title.select title,MAX(stars)as max_star from rating,Movie where Rating.mID=Movie.mID group by title order by title select title,maxrating from movie,(select mid,max(stars)as maxrating from rating group by mid)as r where movie.mid=r.mid order by title Question 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 rating_spread from rating,Movie where Rating.mID=Movie.mID group by title order by rating_spread desc,title select title,spread as rating spread from movie,(select mid,max(stars)-min(stars)as spread from rating group by mid)as r where movie.mid=r.mid order by spread desc,title Question 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.Dont just calculate the overall average rating before and after 1980.)select F.avg_star-S.avg_star from (select AVG(avg_star)as avg_star from (select Rating.mID,AVG(stars)as avg_star from Rating left join Movie on Rating.mID=Movie.mID where year=1980 group by Rating.mID )as S )as S 文档 select r1979.avgm-r1980.avgm from (select sum(avgrating)/count(*)as avgM from (select avg(stars)as avgrating from rating,movie where movie.mid=rating.mid and year=1980 group by movie.mid)as r)as r1980 Question 10:Add the reviewer Roger Ebert to your database,with an rID of 209.insert into Reviewer values(209,Roger Ebert)Question 11:Insert 5-star ratings by James Cameron for all movies in the database.Leave the review date as NULL.insert into Rating(rID,mID,stars)select rid,mID,5 as stras from movie,(select rid from Reviewer where name=James Cameron)as T insert into rating(rid,mid,stars)select rid,mid,5 from reviewer,movie where name=James Cameron Question 12:For all movies that have an average rating of 4 stars or higher,add 25 to the release year.(Update the existing tuples;dont insert new tuples.)update Movie set year=year+25 文档 where mID in(select mID from Rating group by mID having AVG(stars)=4)*/

    注意事项

    本文(数据库sql习题及答案.pdf)为本站会员(深夜****等你...)主动上传,淘文阁 - 分享文档赚钱的网站仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知淘文阁 - 分享文档赚钱的网站(点击联系客服),我们立即给予删除!

    温馨提示:如果因为网速或其他原因下载失败请重新下载,重复下载不扣分。




    关于淘文阁 - 版权申诉 - 用户使用规则 - 积分规则 - 联系我们

    本站为文档C TO C交易模式,本站只提供存储空间、用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。本站仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知淘文阁网,我们立即给予删除!客服QQ:136780468 微信:18945177775 电话:18904686070

    工信部备案号:黑ICP备15003705号 © 2020-2023 www.taowenge.com 淘文阁 

    收起
    展开