我有两个表Order和Transaction
订单表格
id | OrderId | TransId订单日期 | ||
---|---|---|---|---|
1 | 54 | 11151 | 2021年1月12日||
2 | 55 | 111552 | 2021年2月12日||
3 | 56 | 11553 | 2021年2月12日 | |
4 | 57 | 11554 | 2021年5月12日 | |
5 | 58 | 11555 | 2021年8月12日 | |
6 | 59 | 11556 | 2021年9月12日
select t.paymentMethod, sum(t.amount) from tbl_order o
inner join tbl_transaction t on o.orderId = t.orderId
where t.paymentMethod = 'CASH' and o.orderDate between start_date and end_date
group by t.paymentMethod;