Merchant table
The column name | annotation |
---|---|
id | Merchant id |
city | city |
Transaction flow statement (transaction_flow)
The column name | annotation |
---|---|
m_id | Merchant id |
amount | Transaction amount |
time | Trading hours |
Please write SQL to query the monthly sales performance of each city.
SELECT
m.city, YEAR(t.time), MONTH(t.time), SUM(t.amount)
FROM
transaction_flow t
LEFT JOIN merchant m ON t.m_id = m.id
GROUP BY m.city, YEAR(t.time), MONTH(t.time);
Copy the code
Friendship tips: the topic comes from each real enterprise, the above answers are for reference only, can not determine whether to meet the topic to examine the knowledge point!