网站做优化甜点的网站建设规划书
网站做优化,甜点的网站建设规划书,装饰公司名称大全简单大气,延庆手机网站建设Sqlzoo习题练习#xff1a;More JOIN operations下面会涉及到更多连接的概念。数据库由三个表组成#xff1a;movie , actor 和 casting以及三个表之间的关系。下面为More JOIN 习题内容#xff1a;--#1/*List the films where the yr is 1962 [Show id, title]*/SELECT id,…Sqlzoo习题练习More JOIN operations下面会涉及到更多连接的概念。数据库由三个表组成movie , actor 和 casting以及三个表之间的关系。下面为More JOIN 习题内容--#1/*List the films where the yr is 1962 [Show id, title]*/SELECT id, titleFROM movieWHERE yr1962;--#2/*Give year of Citizen Kane.*/SELECT yrFROM movieWHERE title Citizen Kane;--#3/*List all of the Star Trek movies, include the id, title and yr (all of these movies include the words Star Trek in the title). Order results by year.*/SELECT id,title,yrFROM movieWHERE title LIKE Star Trek%;--#4/*What id number does the actor Glenn Close have?*/SELECT id FROM actorWHERE name Glenn Close;--#5/*What is the id of the film Casablanca*/SELECT idFROM movieWHERE title Casablanca;--#6/*Obtain the cast list for Casablanca.what is a cast list?The cast list is the names of the actors who were in the movie.Use movieid11768, (or whatever value you got from the previous question)*/SELECT actor.nameFROM actor JOIN casting ON (actor.idcasting.actorid)WHERE casting.movieid 11768;--#7/*Obtain the cast list for the film Alien*/SELECT actor.nameFROM actor JOIN castingON (actor.idcasting.actorid)JOIN movieON (movie.id casting.movieid)WHERE movie.title Alien ;--#8/*List the films in which Harrison Ford has appeared*/SELECT movie.titleFROM actor JOIN castingON (actor.idcasting.actorid)JOIN movieON (movie.id casting.movieid)WHERE actor.name Harrison Ford;--#9/*List the films where Harrison Ford has appeared - but not in the starring role. [Note: the ord field of casting gives the position of the actor. If ord1 then this actor is in the starring role]*/SELECT movie.titleFROM actor JOIN castingON (actor.idcasting.actorid)JOIN movieON (movie.id casting.movieid)WHERE actor.name Harrison Ford AND casting.ord ! 1;--#10/*List the films together with the leading star for all 1962 films.*/SELECT movie.title,actor.nameFROM actor JOIN castingON (actor.idcasting.actorid)JOIN movieON (movie.id casting.movieid)WHERE movie.yr 1962AND casting.ord 1;知识点MAX() 函数MAX 函数返回一列中的最大值。NULL 值不包括在计算中。MAX() 语法SELECT MAX(column_name) FROM table_name--#11/*Which were the busiest years for John Travolta, show the year and the number of movies he made each year for any year in which he made more than 2 movies.*/SELECT yr,COUNT(title) FROMmovie JOIN casting ON movie.idmovieidJOIN actor ON actoridactor.idwhere nameJohn TravoltaGROUP BY yrHAVING COUNT(title)(SELECT MAX(c) FROM(SELECT yr,COUNT(title) AS c FROMmovie JOIN casting ON movie.idmovieidJOIN actor ON actoridactor.idwhere nameJohn TravoltaGROUP BY yr) AS t)--#12/*List the film title and the leading actor for all of the films Julie Andrews played in.Did you get Little Miss Marker twice?Julie Andrews starred in the 1980 remake of Little Miss Marker and not the original(1934).Title is not a unique field, create a table of IDs in your subquery*/SELECT DISTINCT m.title,a.nameFROM (SELECT movie.*FROM actor JOIN castingON (actor.idcasting.actorid)JOIN movieON (movie.id casting.movieid)WHERE actor.name Julie Andrews) AS mJOIN (SELECT actor.*,casting.movieid AS movieidFROM actor JOIN castingON (actor.idcasting.actorid)WHERE casting.ord 1) AS aON m.id a.movieidORDER BY m.title;--#13/*Obtain a list, in alphabetical order, of actors whove had at least 30 starring roles.*/SELECT actor.nameFROM actorJOIN castingon (actor.id casting.actorid)WHERE casting.ord 1GROUP BY actor.nameHAVING COUNT(*) 30;--#14/*List the films released in the year 1978 ordered by the number of actors in the cast, then by title.*/SELECT movie.title, COUNT(actorid) AS cast_actorsFROM movieJOIN castingON movie.id casting.movieidJOIN actorON actor.id casting.actoridWHERE movie.yr 1978GROUP BY movie.titleORDER BY cast_actors DESC,movie.title;--#15/*List all the people who have worked with Art Garfunkel.*/SELECT a.nameFROM (SELECT movie.*FROM movieJOIN castingON casting.movieid movie.idJOIN actorON actor.id casting.actoridWHERE actor.name Art Garfunkel) AS mJOIN (SELECT actor.*, casting.movieidFROM actorJOIN castingON casting.actorid actor.idWHERE actor.name ! Art Garfunkel) as aON m.id a.movieid;
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/pingmian/88042.shtml
如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!