Skip to content

Commit 79b935f

Browse files
committed
feat: add solutions to lc problem: No.1212
No.1212.Team Scores in Football Tournament
1 parent 4fefc13 commit 79b935f

File tree

3 files changed

+30
-2
lines changed

3 files changed

+30
-2
lines changed

solution/1200-1299/1212.Team Scores in Football Tournament/README.md

+10-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,16 @@ Teams </code>table:
100100
### **SQL**
101101

102102
```sql
103-
103+
# Write your MySQL query statement below
104+
SELECT t.team_id
105+
,t.team_name
106+
,SUM(CASE WHEN t.team_id = m.host_team AND m.host_goals > m.guest_goals THEN 3 WHEN m.host_goals = m.guest_goals THEN 1 WHEN t.team_id = m.guest_team AND m.guest_goals > m.host_goals THEN 3 ELSE 0 END) AS num_points
107+
FROM Teams t
108+
LEFT JOIN Matches m
109+
ON t.team_id = m.host_team OR t.team_id = m.guest_team
110+
GROUP BY t.team_id
111+
ORDER BY num_points DESC
112+
,team_id;
104113
```
105114

106115
<!-- tabs:end -->

solution/1200-1299/1212.Team Scores in Football Tournament/README_EN.md

+10-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,16 @@ Matches table:
9595
### **SQL**
9696

9797
```sql
98-
98+
# Write your MySQL query statement below
99+
SELECT t.team_id
100+
,t.team_name
101+
,SUM(CASE WHEN t.team_id = m.host_team AND m.host_goals > m.guest_goals THEN 3 WHEN m.host_goals = m.guest_goals THEN 1 WHEN t.team_id = m.guest_team AND m.guest_goals > m.host_goals THEN 3 ELSE 0 END) AS num_points
102+
FROM Teams t
103+
LEFT JOIN Matches m
104+
ON t.team_id = m.host_team OR t.team_id = m.guest_team
105+
GROUP BY t.team_id
106+
ORDER BY num_points DESC
107+
,team_id;
99108
```
100109

101110
<!-- tabs:end -->
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Write your MySQL query statement below
2+
SELECT t.team_id
3+
,t.team_name
4+
,SUM(CASE WHEN t.team_id = m.host_team AND m.host_goals > m.guest_goals THEN 3 WHEN m.host_goals = m.guest_goals THEN 1 WHEN t.team_id = m.guest_team AND m.guest_goals > m.host_goals THEN 3 ELSE 0 END) AS num_points
5+
FROM Teams t
6+
LEFT JOIN Matches m
7+
ON t.team_id = m.host_team OR t.team_id = m.guest_team
8+
GROUP BY t.team_id
9+
ORDER BY num_points DESC
10+
,team_id;

0 commit comments

Comments
 (0)