Practice Monthly Transactions I
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
Tables: Transactions(id INT, country VARCHAR, state ENUM, amount INT, trans_date DATE). Transactions.id is unique. state is approved or declined. Group by calendar month and country. Return month in YYYY-MM form, country, trans_count, approved_count, trans_total_amount and approved_total_amount. Count and sum all transactions for the overall measures and only approved transactions for the approved measures. Output order is unrestricted.
Source: Monthly Transactions I on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
Transactions table: +------+---------+----------+--------+------------+ | id | country | state | amount | trans_date | +------+---------+----------+--------+------------+ | 121 | US | approved | 1000 | 2018-12-18 | | 122 | US | declined | 2000 | 2018-12-19 | | 123 | US | approved | 2000 | 2019-01-01 | | 124 | DE | approved | 2000 | 2019-01-07 | +------+---------+----------+--------+------------+
+----------+---------+-------------+----------------+--------------------+-----------------------+ | month | country | trans_count | approved_count | trans_total_amount | approved_total_amount | +----------+---------+-------------+----------------+--------------------+-----------------------+ | 2018-12 | US | 2 | 1 | 3000 | 1000 | | 2019-01 | US | 1 | 1 | 2000 | 2000 | | 2019-01 | DE | 1 | 1 | 2000 | 2000 | +----------+---------+-------------+----------------+--------------------+-----------------------+
Related LeetCode Problems
Practice more problems similar to Monthly Transactions I.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.