The JOIN operation -- SQLZOO
The JOIN operation
注意:where语句中对表示条件的需要用单引号, 下面的译文使用的是有道翻译如有不正确,请直接投诉有道
01.Modify it to show the matchid and player name for all goals scored by Germany. To identify German players, check for: teamid = 'GER
译文:修改后显示德国队所有进球的比赛id和球员名字。要确定德国球员,请检查:teamid = 'GER'
SELECT matchid, player FROM goal
WHERE teamid = 'GER';
02.Show id, stadium, team1, team2 for just game 1012
SELECT id,stadium,team1,team2
FROM game
WHERE id = 1012;
03.Modify it to show the player, teamid, stadium and mdate for every German goal.
译文:修改它,显示球员,teamid,体育场和mdate为每个德国进球。
SELECT player, teamid, stadium, mdate FROM game JOIN goal ON (id=matchid) WHERE teamid = 'GER';
04.Show the team1, team2 and player for every goal scored by a player called Mario player LIKE 'Mario%'
译文:展示一个叫马里奥的球员(比如“马里奥%”)每进一球的团队1、团队2和球员。
SELECT team1, team2, player FROM game JOIN goal ON (id=matchid) WHERE player LIKE 'Mario%';
05.Show player
, teamid
, coach
, gtime
for all goals scored in the first 10 minutes gtime<=10
译文:显示球员,teamid,教练,在前10分钟内所有的进球gtime<=10
SELECT player, teamid,coach, gtime FROM goal JOIN eteam on teamid=id WHERE gtime<=10;
06.List the dates of the matches and the name of the team in which 'Fernando Santos' was the team1 coach.
译文:请列出比赛日期和由“费尔南多·桑托斯”担任球队教练的球队名称。
SELECT mdate, teamname FROM game JOIN eteam on (team1=eteam.id) WHERE coach = 'Fernando Santos';
07.List the player for every goal scored in a game where the stadium was 'National Stadium, Warsaw'
译文:列出球场为“华沙国家体育场”的比赛中每进一球的球员名单
SELECT player FROM game JOIN goal ON (id=matchid) WHERE stadium = 'National Stadium, Warsaw'
08.Instead show the name of all players who scored a goal against Germany.
译文:显示所有在对德国队的比赛中进球的球员的名字。
SELECT DISTINCT player FROM game JOIN goal ON matchid = id WHERE (team1='GER' AND teamid != 'GER') OR (team2='GER' AND teamid != 'GER');
09.Show teamname and the total number of goals scored.
译文:显示球队名称和进球总数
SELECT teamname, COUNT(player) FROM eteam JOIN goal ON id=teamid GROUP BY teamname;
10.Show the stadium and the number of goals scored in each stadium.
译文:显示球场和每个球场的进球数
SELECT stadium, COUNT(player) FROM game JOIN goal ON id=matchid GROUP BY stadium;
11.For every match involving 'POL', show the matchid, date and the number of goals scored.
译文:对于每一场涉及“POL”的比赛,显示比赛id、日期和进球次数。
SELECT DISTINCT matchid, mdate, COUNT(teamid) FROM game JOIN goal ON matchid = id WHERE team1 = 'POL' OR team2 = 'POL' group by matchid, mdate;
12.For every match where 'GER' scored, show matchid, match date and the number of goals scored by 'GER'
译文:对于每一场“GER”进球的比赛,显示matchid、比赛日期和“GER”进球的次数
SELECT DISTINCT matchid, mdate, COUNT(teamid) FROM game JOIN goal ON matchid = id WHERE ( team1 = 'GER' AND teamid = 'GER') OR (team2 = 'GER' AND teamid = 'GER') group by matchid, mdate;
13.Sort your result by mdate, matchid, team1 and team2.
译文:根据mdate, matchid, team1和team2对你的结果排序。
# 写不出来
练习网址:https://sqlzoo.net/wiki/The_JOIN_operation
——————————————————————————————————————————————————————————————————————————————————————————————————————————
The JOIN operation -- SQLZOO的更多相关文章
- More JOIN operations -- SQLZOO
The JOIN operation 注意:where语句中对表示条件的需要用单引号, 下面的译文使用的是有道翻译如有不正确,请直接投诉有道 01.List the films where the y ...
- mysql练习----The JOIN operation
game id mdate stadium team1 team2 1001 8 June 2012 National Stadium, Warsaw POL GRE 1002 8 June 2012 ...
- SQLZOO 习题
https://sqlzoo.net 8. 美國.印度和中國(USA, India, China)是人口又大,同時面積又大的國家.排除這些國家. 顯示以人口或面積為大國的國家,但不能同時兩者.顯示國家 ...
- Java Concurrency - Fork/Join Framework
Normally, when you implement a simple, concurrent Java application, you implement some Runnable obje ...
- Spark RDD/Core 编程 API入门系列 之rdd案例(map、filter、flatMap、groupByKey、reduceByKey、join、cogroupy等)(四)
声明: 大数据中,最重要的算子操作是:join !!! 典型的transformation和action val nums = sc.parallelize(1 to 10) //根据集合创建RDD ...
- Join Algorithm
Join(SQL) An SQL join clause combines columns from one or more tables in a relational database. It c ...
- Chapter 4 Left Outer Join in MapReduce
4.1 Introdution Consider a company such as Amazon, which has over 200 millions of users and possibly ...
- Map Reduce Application(Join)
We are going to explain how join works in MR , we will focus on reduce side join and map side join. ...
- JavaPersistenceWithHibernate第二版笔记-第六章-Mapping inheritance-006Mixing inheritance strategies(@SecondaryTable、@PrimaryKeyJoinColumn、<join fetch="select">)
一.结构 For example, you can map a class hierarchy to a single table, but, for a particular subclass, s ...
随机推荐
- 113资讯网:安装程序进入Admin后台出现:SQLSTATE[HY000] [1045] Access denied for user'root'@'localhost' (using password: YES)
各项设置设置正确,就是出现这种原因! 1.config.inc.php解决办法: 修改phpMyAdmin的配置文件里的密码设置,进入phpMyAdmin的安装目录,找到config.inc.php配 ...
- Code Forces 833 A The Meaningless Game(思维,数学)
Code Forces 833 A The Meaningless Game 题目大意 有两个人玩游戏,每轮给出一个自然数k,赢得人乘k^2,输得人乘k,给出最后两个人的分数,问两个人能否达到这个分数 ...
- 基于html5拖拽api实现列表的拖拽排序
基于html5拖拽api实现列表的拖拽排序 html代码: <ul ondrop="drop_handler(event);" ondragover="dragov ...
- SQLAlchemy(三):外键、连表关系
SQLAlchemy03 /外键.连表关系 目录 SQLAlchemy03 /外键.连表关系 1.外键 2.ORM关系以及一对多 3.一对一的关系 4.多对多的关系 5.ORM层面的删除数据 6.OR ...
- Python函数07/有参装饰器/多个装饰器装饰一个函数
Python函数07/有参装饰器/多个装饰器装饰一个函数 目录 Python函数07/有参装饰器/多个装饰器装饰一个函数 内容大纲 1.有参装饰器 2.多个装饰器装饰一个函数 3.今日总结 3.今日练 ...
- 分布式任务调度平台 → XXL-JOB 初探
开心一刻 旁边的女乘客太吵,我实在忍无可忍,便对她说:“你能不能让我睡会儿?” 她挥手就给了我一个耳光:“你个臭流氓!” 我顿时就清醒了,理论到:“你让我睡一会怎么了吗” 她害羞的低下了头,说道:“人 ...
- git的撤销、删除和版本回退
目录 备注: 知识点: 查看git仓库的状态 查看历史记录. 版本回退 备注: 本文参考于廖雪峰的博客Git教程.依照其博客进行学习和记录,感谢其无私分享,也欢迎各位查看原文. 知识点: 1.git ...
- 六十来行python代码完成一个文件分类器
你的桌面是否像这样的一样被各种文件给堆满了,但是每一个文件又不清楚是否后面还有作用,也不敢删除,自己一个一个转移又太麻烦了.没关系,今天我带大家用python一起来做一个文件归类器,一键进行 ...
- Apache Tomcat目录结构与版本升级
升级原因: 由于当前操作系统内的tomcat版本过低,存在大量高中危漏洞,存在一定的安全隐患.如下图所示,使用绿盟扫描器进行扫描爆出大量漏洞. 升级思路: 既然决定要升级,那么我觉得首先要做的就是自己 ...
- Django Models随机获取指定数量数据方法
方法一:新增models的Manager方法 下面就直接发代码了 class RandomManager(models.Manager): def get_queryset(self): return ...