LeetCode(数据库)- 可疑银行账户

简介: LeetCode(数据库)- 可疑银行账户

题目链接:点击打开链接

题目大意:略。

解题思路:略。

AC 代码

WITH t AS(SELECT t.account_id, SUM(amount) total, MONTH(day) mon, max_income
FROM Transactions t JOIN Accounts a USING(account_id)
WHERE type = 'Creditor'
GROUP BY 1, 3
HAVING total > max_income
ORDER BY account_id, mon)
SELECT DISTINCT account_id
FROM t t1
WHERE (account_id, mon + 1) IN (SELECT account_id, mon FROM t WHERE account_id = t1.account_id)
目录
相关文章
|
数据库
数据库LeetCode每日练习(三)
数据库LeetCode每日练习(三)
数据库LeetCode每日练习(三)
|
SQL 数据库
数据库LeetCode每日练习(二)
数据库LeetCode每日练习(二)
数据库LeetCode每日练习(二)
|
SQL 数据库
数据库LeetCode每日练习(一)
数据库LeetCode每日练习(一)
数据库LeetCode每日练习(一)
|
数据库
LeetCode(数据库)- 2142. The Number of Passengers in Each Bus I
LeetCode(数据库)- 2142. The Number of Passengers in Each Bus I
335 0
|
数据库
LeetCode(数据库)- The Number of Seniors and Juniors to Join the Company II
LeetCode(数据库)- The Number of Seniors and Juniors to Join the Company II
233 0
|
数据库
LeetCode(数据库)- Number of Accounts That Did Not Stream
LeetCode(数据库)- Number of Accounts That Did Not Stream
232 0
|
数据库
LeetCode(数据库)- The Airport With the Most Traffic
LeetCode(数据库)- The Airport With the Most Traffic
257 0
|
数据库
LeetCode(数据库)- The Category of Each Member in the Store
LeetCode(数据库)- The Category of Each Member in the Store
214 0
|
数据库
LeetCode(数据库)- 账户余额
LeetCode(数据库)- 账户余额
218 0
|
数据库
LeetCode(数据库)- 上级经理已离职的公司员工
LeetCode(数据库)- 上级经理已离职的公司员工
312 0