{ "data": { "question": { "questionId": "3530", "questionFrontendId": "3220", "boundTopicId": null, "title": "Odd and Even Transactions", "titleSlug": "odd-and-even-transactions", "content": "
Table: transactions
\n+------------------+------+\n| Column Name | Type | \n+------------------+------+\n| transaction_id | int |\n| amount | int |\n| transaction_date | date |\n+------------------+------+\nThe transactions_id column uniquely identifies each row in this table.\nEach row of this table contains the transaction id, amount and transaction date.\n\n\n
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.
The result format is in the following example.
\n\n\n
Example:
\n\nInput:
\n\ntransactions
table:
\n+----------------+--------+------------------+\n| transaction_id | amount | transaction_date |\n+----------------+--------+------------------+\n| 1 | 150 | 2024-07-01 |\n| 2 | 200 | 2024-07-01 |\n| 3 | 75 | 2024-07-01 |\n| 4 | 300 | 2024-07-02 |\n| 5 | 50 | 2024-07-02 |\n| 6 | 120 | 2024-07-03 |\n+----------------+--------+------------------+\n\n\n
Output:
\n\n\n+------------------+---------+----------+\n| transaction_date | odd_sum | even_sum |\n+------------------+---------+----------+\n| 2024-07-01 | 75 | 350 |\n| 2024-07-02 | 0 | 350 |\n| 2024-07-03 | 0 | 120 |\n+------------------+---------+----------+\n\n\n
Explanation:
\n\nNote: The output table is ordered by transaction_date
in ascending order.
MySQL 8.0
.
mssql server 2019
.
Oracle Sql 11.2
.
Python 3.10 with Pandas 2.0.2 and NumPy 1.25.0
\"], \"postgresql\": [\"PostgreSQL\", \"PostgreSQL 16
\"]}", "libraryUrl": null, "adminUrl": null, "challengeQuestion": null, "__typename": "QuestionNode" } } }