0
点赞
收藏
分享

微信扫一扫

LeetCode(数据库)- 不同性别每日分数总计


题目链接:​​点击打开链接​​

题目大意:略。

解题思路:略。

AC 代码

-- 解决方案(1)
SELECT s1.gender, s1.day, SUM(s2.score_points) AS total
FROM Scores AS s1, Scores AS s2
WHERE s1.gender = s2.gender AND s1.day >= s2.day
GROUP BY s1.gender, s1.day
ORDER BY s1.gender, s1.day;

-- 解决方案(2)
SELECT gender, day, SUM(score_points) OVER w AS total
FROM Scores
WINDOW w AS (PARTITION BY gender ORDER BY day);

-- 解决方案(3)
SELECT gender, day, SUM(score_points) OVER(PARTITION BY gender ORDER BY gender, day) total
FROM Scores


举报

相关推荐

0 条评论