Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit4139ffd

Browse files
committed
Update README.md
1 parent0e79b7d commit4139ffd

File tree

1 file changed

+54
-2
lines changed

1 file changed

+54
-2
lines changed

‎README.md‎

Lines changed: 54 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,59 @@ FROM (
252252
WHEREtemp.od=1
253253
```
254254

255-
<!--[550. Game Play Analysis IV](https://leetcode.com/problems/game-play-analysis-iv/)
255+
[550. Game Play Analysis IV](https://leetcode.com/problems/game-play-analysis-iv/)
256256
```sql
257+
WITH login_dateAS (SELECT player_id,MIN(event_date)AS first_login
258+
FROM Activity
259+
GROUP BY player_id),
257260

258-
```-->
261+
recent_loginAS (
262+
SELECT*, DATE_ADD(first_login, INTERVAL1 DAY)AS next_day
263+
FROM login_date)
264+
265+
SELECT ROUND((SELECTCOUNT(DISTINCT(player_id))
266+
FROM Activity
267+
WHERE (player_id, event_date)IN
268+
(SELECT player_id, next_dayFROM recent_login))/ (SELECTCOUNT(DISTINCT player_id)FROM Activity),2)AS fraction
269+
```
270+
[2356. Number of Unique Subjects Taught by Each Teacher](https://leetcode.com/problems/number-of-unique-subjects-taught-by-each-teacher)
271+
```sql
272+
SELECT teacher_id,COUNT(DISTINCT subject_id) cnt
273+
FROM Teacher
274+
GROUP BY teacher_id
275+
```
276+
277+
[1141. User Activity for the Past 30 Days I](https://leetcode.com/problems/user-activity-for-the-past-30-days-i/)
278+
```sql
279+
SELECT activity_dateas day,COUNT(DISTINCT user_id)AS active_users
280+
FROM Activity
281+
WHERE activity_date BETWEEN DATE_SUB('2019-07-27', INTERVAL29 DAY)AND'2019-07-27'
282+
GROUP BY activity_date
283+
```
284+
285+
[1070. Product Sales Analysis III
286+
](https://leetcode.com/problems/product-sales-analysis-iii/)
287+
```sql
288+
SELECTs.product_id,s.yearAS first_year,s.quantity,s.price
289+
FROM Sales s
290+
JOIN (
291+
SELECT product_id,MIN(year)AS year
292+
FROM sales
293+
GROUP BY product_id
294+
) p
295+
ONs.product_id=p.product_id
296+
ANDs.year=p.year
297+
298+
-- OR
299+
WITH first_year_salesAS (
300+
SELECTs.product_id,MIN(s.year)as first_year
301+
FROM Sales s
302+
INNER JOIN Product p
303+
ONs.product_id=p.product_id
304+
GROUP BYs.product_id)
305+
SELECTf.product_id,f.first_year,s.quantity,s.price
306+
FROM first_year_sales f
307+
JOIN Sales s
308+
ONf.product_id=s.product_id
309+
ANDf.first_year=s.year
310+
```

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp