1193. Monthly Transactions I LeetCode Solution
In this guide, you will get 1193. Monthly Transactions I LeetCode Solution with the best time and space complexity. The solution to Monthly Transactions I problem is provided in various programming languages like C++, Java, and Python. This will be helpful for you if you are preparing for placements, hackathons, interviews, or practice purposes. The solutions provided here are very easy to follow and include detailed explanations.
Table of Contents
- Problem Statement
- Complexity Analysis
- Monthly Transactions I solution in C++
- Monthly Transactions I solution in Java
- Monthly Transactions I solution in Python
- Additional Resources

Problem Statement of Monthly Transactions I
Table: Transactions
+—————+———+
| Column Name | Type |
+—————+———+
| id | int |
| country | varchar |
| state | enum |
| amount | int |
| trans_date | date |
+—————+———+
id is the primary key of this table.
The table has information about incoming transactions.
The state column is an enum of type [“approved”, “declined”].
Write an SQL query to find for each month and country, the number of transactions and their total amount, the number of approved transactions and their total amount.
Return the result table in any order.
The query result format is in the following example.
Example not found
Constraints not found
Complexity Analysis
- Time Complexity: Google AdSense
- Space Complexity: Google Analytics
1193. Monthly Transactions I LeetCode Solution in C++
SELECT
DATE_FORMAT(trans_date, '%Y-%m') AS month,
country,
COUNT(*) AS trans_count,
SUM(state = 'approved') AS approved_count,
SUM(amount) AS trans_total_amount,
SUM(IF(state = 'approved', amount, 0)) AS approved_total_amount
FROM Transactions
GROUP BY 1, 2;
/* code provided by PROGIEZ */
1193. Monthly Transactions I LeetCode Solution in Java
N/A
// code provided by PROGIEZ
1193. Monthly Transactions I LeetCode Solution in Python
N/A
# code by PROGIEZ
Additional Resources
- Explore all LeetCode problem solutions at Progiez here
- Explore all problems on LeetCode website here
Happy Coding! Keep following PROGIEZ for more updates and solutions.