当前位置:网站首页>【每日SQL打卡】DAY 25丨不同性别每日分数总计【难度中等】
【每日SQL打卡】DAY 25丨不同性别每日分数总计【难度中等】
2022-07-29 11:42:00 【不吃西红柿】
难度中等
SQL架构
表: Scores
+---------------+---------+
| Column Name | Type |
+---------------+---------+
| player_name | varchar |
| gender | varchar |
| day | date |
| score_points | int |
+---------------+---------+
(gender, day)是该表的主键
一场比赛是在女队和男队之间举行的
该表的每一行表示一个名叫 (player_name) 性别为 (gender) 的参赛者在某一天获得了 (score_points) 的分数
如果参赛者是女性,那么 gender 列为 'F',如果参赛者是男性,那么 gender 列为 'M'
写一条SQL语句查询每种性别在每一天的总分,并按性别和日期对查询结果排序
下面是查询结果格式的例子:
Scores表:
+-------------+--------+------------+--------------+
| player_name | gender | day | score_points |
+-------------+--------+------------+--------------+
| Aron | F | 2020-01-01 | 17 |
| Alice | F | 2020-01-07 | 23 |
| Bajrang | M | 2020-01-07 | 7 |
| Khali | M | 2019-12-25 | 11 |
| Slaman | M | 2019-12-30 | 13 |
| Joe | M | 2019-12-31 | 3 |
| Jose | M | 2019-12-18 | 2 |
| Priya | F | 2019-12-31 | 23 |
| Priyanka | F | 2019-12-30 | 17 |
+-------------+--------+------------+--------------+
结果表:
+--------+------------+-------+
| gender | day | total |
+--------+------------+-------+
| F | 2019-12-30 | 17 |
| F | 2019-12-31 | 40 |
| F | 2020-01-01 | 57 |
| F | 2020-01-07 | 80 |
| M | 2019-12-18 | 2 |
| M | 2019-12-25 | 13 |
| M | 2019-12-30 | 26 |
| M | 2019-12-31 | 29 |
| M | 2020-01-07 | 36 |
+--------+------------+-------+
女性队伍:
第一天是 2019-12-30,Priyanka 获得 17 分,队伍的总分是 17 分
第二天是 2019-12-31, Priya 获得 23 分,队伍的总分是 40 分
第三天是 2020-01-01, Aron 获得 17 分,队伍的总分是 57 分
第四天是 2020-01-07, Alice 获得 23 分,队伍的总分是 80 分
男性队伍:
第一天是 2019-12-18, Jose 获得 2 分,队伍的总分是 2 分
第二天是 2019-12-25, Khali 获得 11 分,队伍的总分是 13 分
第三天是 2019-12-30, Slaman 获得 13 分,队伍的总分是 26 分
第四天是 2019-12-31, Joe 获得 3 分,队伍的总分是 29 分
第五天是 2020-01-07, Bajrang 获得 7 分,队伍的总分是 36 分
边栏推荐
- c语言:来实现一个小程序n子棋(已五子棋为例)
- Is this it?TypeScript actually not difficult!(recommended collection)
- HMS Core Discovery 16 review | with tiger mound, embracing new AI "voice" state
- Learning with Recoverable Forgetting阅读心得
- golang 实现文件上传下载
- One click blog building: how to use WordPress plug-in to build a dedicated blog
- Exclusive interview | Cheng Li, chief technology officer of Alibaba: cloud + open source together form a credible foundation for the digital world
- GDB使用详解
- 自采集在线电脑壁纸php源码v2.0自适应端
- 精通音视频开发是真的可以为所欲为
猜你喜欢
[image detection] Research on cumulative weighted edge detection method based on gray image, with matlab code
惠及6亿人 投资98亿 沿江高铁武宜段最新进展来了!
How to use "copy – link" to accelerate docker to build and optimize cache
7月3日文: 表面上有危险,实属安全周期,大概率会快速上扬的个股
通过递归的方式实现树形结构
Niuke net brush questions
宝塔快速搭建自适应咖啡网站模板与管理系统源码实测
AI全流程开发难题破解之钥
Proficient in audio and video development can really do whatever you want
报表查询字段集sql摘记
随机推荐
Out-of-the-box problem-solving thinking, putting a "rearview mirror" on the unconscious life
SkiaSharp of WPF custom painting to bounce ball (case)
Learn weekly - 64 - a v2ex style source BBS program
【表达式计算】表达式计算问题的通用解法(练习加强版,含总结)
MarkDown高阶语法手册
通过递归的方式实现树形结构
Deep understanding of c # delegate into the fast lanes
Flink UDF 函数汇总
QT's user-defined interface (borderless and movable)
一次node文件操作过多排查过程总结
QWidget、QDialog、QMainWindow 的异同点
2022年企业直播行业发展洞察
2.3插入排序
小笑授权系统V5.0开心版
7月3日文: 表面上有危险,实属安全周期,大概率会快速上扬的个股
ECCV 2022 | SSP: 自支持匹配的小样本任务新思想
宝塔快速搭建自适应咖啡网站模板与管理系统源码实测
[image detection] Research on cumulative weighted edge detection method based on gray image, with matlab code
Exclusive interview | Cheng Li, chief technology officer of Alibaba: cloud + open source together form a credible foundation for the digital world
如何对SQuAD1.1数据集进行预处理「详解版」