Skip to content

Commit 0434c9c

Browse files
authored
Create odd-and-even-transactions.sql
1 parent eb08b08 commit 0434c9c

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

MySQL/odd-and-even-transactions.sql

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Time: O(nlogn)
2+
# Space: O(1)
3+
4+
SELECT transaction_date,
5+
SUM(IF(amount%2 != 0, amount, 0)) AS odd_sum,
6+
SUM(IF(amount%2 = 0, amount, 0)) AS even_sum
7+
FROM transactions
8+
GROUP BY 1
9+
ORDER BY 1;

0 commit comments

Comments
 (0)