Skip to content

task: #3220 #72

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ Useful for preparing for technical interviews and improving your SQL skills.
- [1393. Capital Gain/Loss](./leetcode/medium/1393.%20Capital%20Gain&Loss.sql)
- [1907. Count Salary Categories](./leetcode/medium/1907.%20Count%20Salary%20Categories.sql)
- [1934. Confirmation Rate](./leetcode/medium/1934.%20Confirmation%20Rate.sql)
- [3220. Odd and Even Transactions](./leetcode/medium/3220.%20Odd%20and%20Even%20Transactions.sql)
- [3475. DNA Pattern Recognition](./leetcode/medium/3475.%20DNA%20Pattern%20Recognition.sql)
- [3497. Analyze Subscription Conversion](./leetcode/medium/3497.%20Analyze%20Subscription%20Conversion.sql)
3. [Hard](./leetcode/hard/)
Expand Down
35 changes: 35 additions & 0 deletions leetcode/medium/3220. Odd and Even Transactions.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
Question 3220. Odd and Even Transactions
Link: https://leetcode.com/problems/odd-and-even-transactions/description/?envType=problem-list-v2&envId=database

Table: transactions

+------------------+------+
| Column Name | Type |
+------------------+------+
| transaction_id | int |
| amount | int |
| transaction_date | date |
+------------------+------+
The transactions_id column uniquely identifies each row in this table.
Each row of this table contains the transaction id, amount and transaction date.
Write a solution to find the sum of amounts for odd and even transactions for each day. If there are no odd or even transactions for a specific date, display as 0.

Return the result table ordered by transaction_date in ascending order.
*/

SELECT
transaction_date,
SUM(CASE
WHEN amount % 2 = 1
THEN amount
ELSE 0
END) AS odd_sum,
SUM(CASE
WHEN amount % 2 = 0
THEN amount
ELSE 0
END) AS even_sum
FROM transactions
GROUP BY transaction_date
ORDER BY transaction_date ASC
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy