Skip to content

Commit addf965

Browse files
committed
Upload 195
1 parent c81ddc7 commit addf965

File tree

2 files changed

+55
-1
lines changed

2 files changed

+55
-1
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<!-- markdownlint-disable MD041 -->
22
[![eevveerryyddaayy release](https://img.shields.io/badge/eevveerryyddaayy-v1.3.0-blue.svg)](https://github.com/ggeerraarrdd/eevveerryyddaayy/)
3-
[![Solved](https://img.shields.io/badge/solved-194-green.svg)](#index)
3+
[![Solved](https://img.shields.io/badge/solved-195-green.svg)](#index)
44
<!-- markdownlint-enable MD041 -->
55

66
# SQL Everyday
@@ -228,6 +228,7 @@ Because this project necessitated a framework to enable consistent daily practic
228228
| 192 | [Find Candidates for Data Scientist Position](https://leetcode.com/problems/find-candidates-for-data-scientist-position/description/) | [Solution](solutions/192_find_candidates_for_data_scientist_position.md) | LeetCode | Easy | |
229229
| 193 | [Classifying Triangles by Lengths](https://leetcode.com/problems/classifying-triangles-by-lengths/description/) | [Solution](solutions/193_classifying_triangles_by_lengths.md) | LeetCode | Easy | |
230230
| 194 | [Reported Posts](https://leetcode.com/problems/reported-posts/description/) | [Solution](solutions/194_reported_posts.md) | LeetCode | Easy | |
231+
| 195 | [Game Play Analysis III](https://leetcode.com/problems/game-play-analysis-iii/description/) | [Solution](solutions/195_game_play_analysis_iii.md) | LeetCode | Medium | |
231232
<!-- Index End - WARNING: Do not delete or modify this markdown comment. -->
232233
<!--- cSpell:enable --->
233234

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# SQL Everyday \#195
2+
3+
## Game Play Analysis III
4+
5+
Site: LeetCode\
6+
Difficulty per Site: Medium
7+
8+
## Problem
9+
10+
Write a solution to report for each player and date, how many games played **so far** by the player. That is, the total number of games played by the player until that date. Check the example for clarity.
11+
12+
Return the result table in **any order**. [[Full Description](https://leetcode.com/problems/game-play-analysis-iii/description/)]
13+
14+
## Submitted Solution
15+
16+
```sql
17+
-- Submitted Solution
18+
SELECT
19+
player_id
20+
,event_date
21+
,SUM(games_played) OVER (PARTITION BY player_id ORDER BY event_date ASC) AS games_played_so_far
22+
FROM Activity
23+
;
24+
```
25+
26+
## Site Solution
27+
28+
```sql
29+
-- LeetCode Solution
30+
-- Non-equi self join
31+
SELECT
32+
A2.player_id,
33+
A2.event_date,
34+
SUM(A1.games_played) AS games_played_so_far
35+
FROM
36+
Activity A1
37+
INNER JOIN Activity A2 ON A1.player_id = A2.player_id
38+
AND A1.event_date <= A2.event_date
39+
GROUP BY
40+
A2.player_id,
41+
A2.event_date;
42+
```
43+
44+
## Notes
45+
46+
TBD
47+
48+
## NB
49+
50+
TBD
51+
52+
Go to [Index](../?tab=readme-ov-file#index)\
53+
Go to [Overview](../?tab=readme-ov-file)

0 commit comments

Comments
 (0)