1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-10 18:48:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode/originData/bank-account-summary-ii.json
2022-05-02 23:44:12 +08:00

84 lines
8.1 KiB
JSON

{
"data": {
"question": {
"questionId": "1734",
"questionFrontendId": "1587",
"boundTopicId": null,
"title": "Bank Account Summary II",
"titleSlug": "bank-account-summary-ii",
"content": "<p>Table: <code>Users</code></p>\n\n<pre>\n+--------------+---------+\n| Column Name | Type |\n+--------------+---------+\n| account | int |\n| name | varchar |\n+--------------+---------+\naccount is the primary key for this table.\nEach row of this table contains the account number of each user in the bank.\n</pre>\n\n<p>&nbsp;</p>\n\n<p>Table: <code>Transactions</code></p>\n\n<pre>\n+---------------+---------+\n| Column Name | Type |\n+---------------+---------+\n| trans_id | int |\n| account | int |\n| amount | int |\n| transacted_on | date |\n+---------------+---------+\ntrans_id is the primary key for this table.\nEach row of this table contains all changes made to all accounts.\namount is positive if the user received money and negative if they transferred money.\nAll accounts start with a balance of 0.\n</pre>\n\n<p>&nbsp;</p>\n\n<p>Write an SQL query to report the name and balance of users with a balance higher than <code>10000</code>. The balance of an account is equal to the sum of the amounts of all transactions involving that account.</p>\n\n<p>Return the result table in <strong>any order</strong>.</p>\n\n<p>The query result format is in the following example.</p>\n\n<p>&nbsp;</p>\n<p><strong>Example 1:</strong></p>\n\n<pre>\n<strong>Input:</strong> \nUsers table:\n+------------+--------------+\n| account | name |\n+------------+--------------+\n| 900001 | Alice |\n| 900002 | Bob |\n| 900003 | Charlie |\n+------------+--------------+\nTransactions table:\n+------------+------------+------------+---------------+\n| trans_id | account | amount | transacted_on |\n+------------+------------+------------+---------------+\n| 1 | 900001 | 7000 | 2020-08-01 |\n| 2 | 900001 | 7000 | 2020-09-01 |\n| 3 | 900001 | -3000 | 2020-09-02 |\n| 4 | 900002 | 1000 | 2020-09-12 |\n| 5 | 900003 | 6000 | 2020-08-07 |\n| 6 | 900003 | 6000 | 2020-09-07 |\n| 7 | 900003 | -4000 | 2020-09-11 |\n+------------+------------+------------+---------------+\n<strong>Output:</strong> \n+------------+------------+\n| name | balance |\n+------------+------------+\n| Alice | 11000 |\n+------------+------------+\n<strong>Explanation:</strong> \nAlice&#39;s balance is (7000 + 7000 - 3000) = 11000.\nBob&#39;s balance is 1000.\nCharlie&#39;s balance is (6000 + 6000 - 4000) = 8000.\n</pre>\n",
"translatedTitle": null,
"translatedContent": null,
"isPaidOnly": false,
"difficulty": "Easy",
"likes": 87,
"dislikes": 3,
"isLiked": null,
"similarQuestions": "[]",
"exampleTestcases": "{\"headers\": {\"Users\": [\"account\", \"name\"], \"Transactions\": [\"trans_id\", \"account\", \"amount\", \"transacted_on\"]}, \"rows\": {\"Users\": [[900001, \"Alice\"], [900002, \"Bob\"], [900003, \"Charlie\"]], \"Transactions\": [[1, 900001, 7000, \"2020-08-01\"], [2, 900001, 7000, \"2020-09-01\"], [3, 900001, -3000, \"2020-09-02\"], [4, 900002, 1000, \"2020-09-12\"], [5, 900003, 6000, \"2020-08-07\"], [6, 900003, 6000, \"2020-09-07\"], [7, 900003, -4000, \"2020-09-11\"]]}}",
"categoryTitle": "Database",
"contributors": [],
"topicTags": [
{
"name": "Database",
"slug": "database",
"translatedName": null,
"__typename": "TopicTagNode"
}
],
"companyTagStats": null,
"codeSnippets": [
{
"lang": "MySQL",
"langSlug": "mysql",
"code": "# Write your MySQL query statement below\n",
"__typename": "CodeSnippetNode"
},
{
"lang": "MS SQL Server",
"langSlug": "mssql",
"code": "/* Write your T-SQL query statement below */\n",
"__typename": "CodeSnippetNode"
},
{
"lang": "Oracle",
"langSlug": "oraclesql",
"code": "/* Write your PL/SQL query statement below */\n",
"__typename": "CodeSnippetNode"
}
],
"stats": "{\"totalAccepted\": \"21.6K\", \"totalSubmission\": \"24K\", \"totalAcceptedRaw\": 21646, \"totalSubmissionRaw\": 24045, \"acRate\": \"90.0%\"}",
"hints": [],
"solution": null,
"status": null,
"sampleTestCase": "{\"headers\": {\"Users\": [\"account\", \"name\"], \"Transactions\": [\"trans_id\", \"account\", \"amount\", \"transacted_on\"]}, \"rows\": {\"Users\": [[900001, \"Alice\"], [900002, \"Bob\"], [900003, \"Charlie\"]], \"Transactions\": [[1, 900001, 7000, \"2020-08-01\"], [2, 900001, 7000, \"2020-09-01\"], [3, 900001, -3000, \"2020-09-02\"], [4, 900002, 1000, \"2020-09-12\"], [5, 900003, 6000, \"2020-08-07\"], [6, 900003, 6000, \"2020-09-07\"], [7, 900003, -4000, \"2020-09-11\"]]}}",
"metaData": "{\n \"mysql\": [\n \"Create table If Not Exists Users (account int, name varchar(20))\",\n \"Create table If Not Exists Transactions (trans_id int, account int, amount int, transacted_on date)\"\n ],\n \"mssql\": [\n \"Create table Users (account int, name varchar(20))\",\n \"Create table Transactions (trans_id int, account int, amount int, transacted_on date)\"\n ],\n \"oraclesql\": [\n \"Create table Users (account int, name varchar(20))\",\n \"Create table Transactions (trans_id int, account int, amount int, transacted_on date)\",\n \"ALTER SESSION SET nls_date_format='YYYY-MM-DD'\"\n ],\n \"database\": true\n}",
"judgerAvailable": true,
"judgeType": "large",
"mysqlSchemas": [
"Create table If Not Exists Users (account int, name varchar(20))",
"Create table If Not Exists Transactions (trans_id int, account int, amount int, transacted_on date)",
"Truncate table Users",
"insert into Users (account, name) values ('900001', 'Alice')",
"insert into Users (account, name) values ('900002', 'Bob')",
"insert into Users (account, name) values ('900003', 'Charlie')",
"Truncate table Transactions",
"insert into Transactions (trans_id, account, amount, transacted_on) values ('1', '900001', '7000', '2020-08-01')",
"insert into Transactions (trans_id, account, amount, transacted_on) values ('2', '900001', '7000', '2020-09-01')",
"insert into Transactions (trans_id, account, amount, transacted_on) values ('3', '900001', '-3000', '2020-09-02')",
"insert into Transactions (trans_id, account, amount, transacted_on) values ('4', '900002', '1000', '2020-09-12')",
"insert into Transactions (trans_id, account, amount, transacted_on) values ('5', '900003', '6000', '2020-08-07')",
"insert into Transactions (trans_id, account, amount, transacted_on) values ('6', '900003', '6000', '2020-09-07')",
"insert into Transactions (trans_id, account, amount, transacted_on) values ('7', '900003', '-4000', '2020-09-11')"
],
"enableRunCode": true,
"enableTestMode": false,
"enableDebugger": false,
"envInfo": "{\"mysql\": [\"MySQL\", \"<p><code>MySQL 8.0</code>.</p>\"], \"mssql\": [\"MS SQL Server\", \"<p><code>mssql server 2019</code>.</p>\"], \"oraclesql\": [\"Oracle\", \"<p><code>Oracle Sql 11.2</code>.</p>\"]}",
"libraryUrl": null,
"adminUrl": null,
"challengeQuestion": null,
"__typename": "QuestionNode"
}
}
}