LeetCode(数据库)- 每月交易 I

阅读 156

2022-05-18


题目链接:​​点击打开链接​​

题目大意:略。

解题思路:略。

AC 代码

SELECT DATE_FORMAT(trans_date, '%Y-%m') month, country, COUNT(*) trans_count, COUNT(IF(state = 'approved', true, null)) approved_count, SUM(amount) trans_total_amount, SUM(IF(state = 'approved', amount, 0)) approved_total_amount
FROM Transactions
GROUP BY month, country


精彩评论(0)

0 0 举报