当前位置: 首页 > news >正文

SQL Zoo 6.The JOIN operation

以下数据均来自SQL Zoo

1.Modify it to show the matchid and player name for all goals scored by Germany. To identify German players, check for: teamid = 'GER'.(它以显示德国所有进球的比赛和球员名字,识别德国球员)

SELECT matchid,player FROM goal where teamid = 'GER'

2.From the previous query you can see that Lars Bender's scored a goal in game 1012. Now we want to know what teams were playing in that match.(从之前的查询中你可以看到拉斯·本德在1012场比赛中进了一个球。现在我们想知道那场比赛是哪支球队.)

SELECT id,stadium,team1,team2FROM game where id = 1012

3.the player (from the goal) and stadium name (from the game table) for every goal scored.Modify it to show the player, teamid, stadium and mdate for every German goal.(每个进球的球员(来自进球)和球场名称(来自比赛表),修改它以显示球员,球队,球场和每个德国队进球的候选人)

SELECT player,teamid,stadium,mdateFROM game JOIN goal ON (id=matchid) where teamid = 'GER'

4.Show the team1, team2 and player for every goal scored by a player called Mario player LIKE 'Mario%'(显示team1, team2和球员的每一个进球被称为马里奥球员)

select team1,team2,player from game join 
goal on game.id = goal.matchid where player like 'Mario%'

5.Show playerteamidcoachgtime for all goals scored in the first 10 minutes gtime<=10.(显示球员,球队,教练,gtime前10分钟内所有进球的gtime<=10)

select player,teamid,coach,gtime from goal 
join eteam on goal.teamid = eteam.id where gtime <=10

6.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 game.team1 = eteam.id where coach = 'Fernando Santos'

7.List the player for every goal scored in a game where the stadium was 'National Stadium, Warsaw'(列出在比赛场地为“华沙国家体育场”的比赛中每个进球的球员)

select player from game 
join goal on game.id = goal.matchid where stadium = 'National Stadium, Warsaw'

8.Show the name of all players who scored a goal against Germany.(显示所有在对阵德国队的比赛中进球的球员的名字)

SELECT distinct playerFROM game JOIN goal ON matchid = id WHERE (team1='GER' or team2='GER') and teamid != 'GER'

9.Show teamname and the total number of goals scored.(显示球队名称和总进球数)

SELECT teamname,count(teamid)FROM eteam JOIN goal ON id=teamidgroup BY teamname

10.Show the stadium and the number of goals scored in each stadium.(显示体育场和每个体育场的进球数)

select stadium,count(matchid) from game 
join goal on game.id = goal.matchid group by stadium

11.For every match involving 'POL', show the matchid, date and the number of goals scored.(对于每一场涉及“POL”的比赛,显示比赛日期和进球数)

select matchid,mdate,count(*) from game 
join goal on id = matchid where team1 = 'POL' or team2='POL' group by matchid

12.For every match where 'GER' scored, show matchid, match date and the number of goals scored by 'GER'(对于每一场“GER”进球的比赛,显示比赛,比赛日期和“GER”进球的数量)

select matchid,mdate,count(teamid) from game 
join goal on id = matchid where teamid = 'GER' group by matchid

13.List every match with the goals scored by each team as shown. If it was a team1 goal then a 1 appears in score1, otherwise there is a 0.  You could SUM this column to get a count of the goals scored by team1.  Sort your result by mdate, matchid, team1 and team2.(列出每一场比赛,如果是team1的进球,则score1中显示1,否则显示0。您可以对这一列进行求和,以获得team1得分的总数。按候选人、配对、team1和team2对结果进行排序。)

SELECT mdate,team1,SUM(CASE WHEN teamid=team1 THEN 1 ELSE 0 END) score1,team2,SUM(CASE WHEN teamid=team2 THEN 1 ELSE 0 END) score2
FROM game 
LEFT JOIN goal 
ON matchid = id
GROUP BY mdate, matchid, team1, team2

相关文章:

SQL Zoo 6.The JOIN operation

以下数据均来自SQL Zoo 1.Modify it to show the matchid and player name for all goals scored by Germany. To identify German players, check for: teamid GER.(它以显示德国所有进球的比赛和球员名字,识别德国球员) SELECT matchid,player FROM goal where teamid GE…...

视频教程:Vue3移动端抽屉弹层组件实战

本教程演示了vue3的composition api实现的移动端h5抽屉弹层组件&#xff0c;录屏讲解包含了功能演示和具体的源码实现。 笔者相关教程&#xff1a; 使用tailwindcss轻松实现移动端rem适配Vue3.4双向绑定新特性&#xff1a;defineModel好用爱用 学习要点&#xff1a; 自定义…...

CSS 的 BFC(块级格式化上下文)

BFC是Block Formatting Context&#xff08;块级格式化上下文&#xff09;的缩写&#xff0c;是CSS中一个概念&#xff0c;用于描述页面上如何对元素进行布局。 BFC是一个独立的容器&#xff0c;它内部的元素不会受到外部容器的影响&#xff0c;同时它也会影响其内部元素的表现…...

【2023年】云计算金砖牛刀小试2

A场次题目:Openstack 平台部署与运维 control172.17.31.10compute172.17.31.20 compute任务1 私有云平台环境初始化 1.初始化操作系统 使用提供的用户名密码,登录竞赛云平台。根据表 1 中的 IP 地址规划,设置各服务器节点的 IP 地址,确保网络正常通信,设置控制节点主机名…...

python--将mysql建表语句转换成hive建表语句

1.代码 import json import sys import pymysqldef queryDataBase(tablename):# 连接数据库并查询列信息conn pymysql.connect(userroot, password123456, hosthadoop11)cursor conn.cursor()cursor.execute("SELECT column_name, data_type FROM information_schema.C…...

异步调用实践:Async,Future, TaskExecutor、EventListener

1. 异步调用概述 异步调用允许一个方法调用在不被当前线程阻塞的情况下继续执行&#xff0c;而调用者可以继续执行其他任务&#xff0c;直到异步操作完成。 在Spring Boot中&#xff0c;异步调用常用于提高应用的响应性和吞吐量&#xff0c;尤其是在处理长时间运行的任务时&a…...

Flask 异常处理

Flask 异常处理 使用 app.errorhandler 装饰器使用 app.handle_exception 装饰器使用 register_error_handler调试模式总结 在 Flask 应用中&#xff0c;异常处理是一个非常重要的部分&#xff0c;它可以帮助你管理运行时错误&#xff0c;提供友好的错误页面&#xff0c;以及记…...

【海思SS626 | 内存管理】海思芯片的OS内存、MMZ内存设置

&#x1f601;博客主页&#x1f601;&#xff1a;&#x1f680;https://blog.csdn.net/wkd_007&#x1f680; &#x1f911;博客内容&#x1f911;&#xff1a;&#x1f36d;嵌入式开发、Linux、C语言、C、数据结构、音视频&#x1f36d; &#x1f923;本文内容&#x1f923;&a…...

linux crontab没有按照规则执行排查

配置了cron规则&#xff0c;但是一段时间后任务没有按预期执行&#xff0c;记录一次修复过程 检查crond服务 systemctl status crond规则正常 crontab -l脚本有执行权限 查看日志 第一种&#xff1a;journalctl journalctl -u crond | grep 03:00 -C 3-u 指定crond.serv…...

Cloudflare的D1使用技巧

总文档&#xff1a;https://developers.cloudflare.com/workers/wrangler/commands/#d1查询某个数据库中哪些命令占用资源最大&#xff1a; To find top 10 queries by execution count: npx wrangler d1 insights <database_name> --sort-typesum --sort-bycount --co…...

解决端口号被占用问题

第一种&#xff1a; 最简单有效的方法&#xff0c;重启一下电脑&#xff0c;占用此端口的程序就会释放端口。 第二种&#xff1a; 使用命令找到占用端口的程序&#xff0c;把它关闭。 1、打开运行窗口输入&#xff1a;CMD &#xff0c;进入命令窗口。 2、输入&#xff1a;n…...

如何在linux上部署zabbix监控工具

<1>搭建服务机 1&#xff09;首先我们先执行 sed -i s/SELINUXenforcing/SELINUXdisabled/ /etc/selinux/config ​ #然后我们再把防火墙开机自启关掉 马上生效 systemctl disable --now firewalld 2&#xff09;我们获得rpm包 rpm -Uvh https://mirrors.aliyun.com/…...

vulnhub系列:sp eric

vulnhub系列&#xff1a;sp eric 靶机下载 一、信息收集 nmap扫描存活&#xff0c;根据mac地址寻找IP nmap 192.168.23.0/24nmap扫描端口&#xff0c;开放端口&#xff1a;22、80 nmap 192.168.23.189 -p- -A -sV -Pndirb 扫描目录&#xff0c;.git 源码&#xff0c;admin…...

JVM二:JVM类加载机制

目录 前言 1.什么是类加载? 2.类加载整体流程 3.一个类什么时候被加载? 4.双亲委派模型 4.1 JVM默认提供了三个类加载器 4.1.1 BootstrapClassLoader 4.1.2 ExtensionClassLoader 4.1.3 ApplicationClassLoader 4.2 破坏双亲委派模型 前言 在上一篇文章中&#xf…...

对于springboot无法连接redis解决方案

对于springboot无法连接redis解决方案 一、测试是否能在本地应用上访问到你的redis&#xff08;如果是部署在linux上的话&#xff09;1. 开启telnet功能2. 开始测试端口是否能访问到&#xff08;适用于所有&#xff0c;包括MQ&#xff09;3. 开放6379端口4. 看spring的配置文件…...

关于android中的各种尺寸与计算

--张学友《心如刀割》很好听 先说几个术语&#xff1a; Screen size(屏幕尺寸)&#xff1a; 指的是手机实际的物理尺寸&#xff0c;比如常用的2.8英寸&#xff0c;3.2英寸&#xff0c;3.5英寸&#xff0c;3.7英寸 摩托罗拉milestone手机是3.7英寸 Aspect Ratio(宽高比率)&am…...

MySQL避免索引失效的方法详细介绍

避免索引失效 在MySQL中&#xff0c;索引是帮助MySQL高效获取数据的数据结构。它就像一本书的目录&#xff0c;通过索引可以快速定位到数据的具体位置&#xff0c;从而减少对数据库的扫描量&#xff0c;提高查询速度。索引可以存储在表中的一个或多个列上&#xff0c;创建索引…...

【Java】深入了解 Java 的 charAt() 方法

我最爱的那首歌最爱的angel 我到什么时候才能遇见我的angel 我最爱的那首歌最爱的angel 我不是王子也会拥有我的angel &#x1f3b5; 张杰《云中的angel》 在 Java 编程中&#xff0c;字符串&#xff08;String&#xff09;是我们经常处理的数据类型之一。…...

Linux 下 ETCD 安装、配置与命令使用总结

​ 大家好&#xff0c;我是程序员小羊&#xff01; 前言&#xff1a; Linux 下 ETCD 安装、配置与命令使用总结 ETCD 是一个分布式键值存储系统&#xff0c;广泛用于服务发现、分布式锁、配置管理等场景&#xff0c;特别是在 Kubernetes 集群中发挥着至关重要的作用。ETCD 的高…...

C++笔试练习笔记【7】:力扣 91. 解码方法 动态规划练习

文章目录 题目题目分析思路解法正常解法优化解法 题目 题目链接&#xff1a;力扣 91. 解码方法 备用链接&#xff1a;https://leetcode.cn/problems/decode-ways/description/ 题目分析 1.首先我们知道题目给定A~Z编码为1 ~26 &#xff0c;而数字十一字符串的形式给出所以…...

CTF show Web 红包题第六弹

提示 1.不是SQL注入 2.需要找关键源码 思路 进入页面发现是一个登录框&#xff0c;很难让人不联想到SQL注入&#xff0c;但提示都说了不是SQL注入&#xff0c;所以就不往这方面想了 ​ 先查看一下网页源码&#xff0c;发现一段JavaScript代码&#xff0c;有一个关键类ctfs…...

大模型多显卡多服务器并行计算方法与实践指南

一、分布式训练概述 大规模语言模型的训练通常需要分布式计算技术,以解决单机资源不足的问题。分布式训练主要分为两种模式: 数据并行:将数据分片到不同设备,每个设备拥有完整的模型副本 模型并行:将模型分割到不同设备,每个设备处理部分模型计算 现代大模型训练通常结合…...

12.找到字符串中所有字母异位词

&#x1f9e0; 题目解析 题目描述&#xff1a; 给定两个字符串 s 和 p&#xff0c;找出 s 中所有 p 的字母异位词的起始索引。 返回的答案以数组形式表示。 字母异位词定义&#xff1a; 若两个字符串包含的字符种类和出现次数完全相同&#xff0c;顺序无所谓&#xff0c;则互为…...

给网站添加live2d看板娘

给网站添加live2d看板娘 参考文献&#xff1a; stevenjoezhang/live2d-widget: 把萌萌哒的看板娘抱回家 (ノ≧∇≦)ノ | Live2D widget for web platformEikanya/Live2d-model: Live2d model collectionzenghongtu/live2d-model-assets 前言 网站环境如下&#xff0c;文章也主…...

Ubuntu Cursor升级成v1.0

0. 当前版本低 使用当前 Cursor v0.50时 GitHub Copilot Chat 打不开&#xff0c;快捷键也不好用&#xff0c;当看到 Cursor 升级后&#xff0c;还是蛮高兴的 1. 下载 Cursor 下载地址&#xff1a;https://www.cursor.com/cn/downloads 点击下载 Linux (x64) &#xff0c;…...

通过MicroSip配置自己的freeswitch服务器进行调试记录

之前用docker安装的freeswitch的&#xff0c;启动是正常的&#xff0c; 但用下面的Microsip连接不上 主要原因有可能一下几个 1、通过下面命令可以看 [rootlocalhost default]# docker exec -it freeswitch fs_cli -x "sofia status profile internal"Name …...

rm视觉学习1-自瞄部分

首先先感谢中南大学的开源&#xff0c;提供了很全面的思路&#xff0c;减少了很多基础性的开发研究 我看的阅读的是中南大学FYT战队开源视觉代码 链接&#xff1a;https://github.com/CSU-FYT-Vision/FYT2024_vision.git 1.框架&#xff1a; 代码框架结构&#xff1a;readme有…...

负载均衡器》》LVS、Nginx、HAproxy 区别

虚拟主机 先4&#xff0c;后7...

ArcGIS Pro+ArcGIS给你的地图加上北回归线!

今天来看ArcGIS Pro和ArcGIS中如何给制作的中国地图或者其他大范围地图加上北回归线。 我们将在ArcGIS Pro和ArcGIS中一同介绍。 1 ArcGIS Pro中设置北回归线 1、在ArcGIS Pro中初步设置好经纬格网等&#xff0c;设置经线、纬线都以10间隔显示。 2、需要插入背会归线&#xf…...

拟合问题处理

在机器学习中&#xff0c;核心任务通常围绕模型训练和性能提升展开&#xff0c;但你提到的 “优化训练数据解决过拟合” 和 “提升泛化性能解决欠拟合” 需要结合更准确的概念进行梳理。以下是对机器学习核心任务的系统复习和修正&#xff1a; 一、机器学习的核心任务框架 机…...