现有两个表如下:borrow_log表中borrower与debtor字段记录着users表的id,写一条SQL统计出每个借钱方欠每个男性债主的款项汇总(gender:1-男,2-女)
参考答案: [SQL] 纯文本查看 复制代码 select borrow_log.borrower,sum(amount) from users
left join borrow_log
on users.id = borrow_log.debtor
where users.gender = 1
group by borrow_log.borrower,borrow_log.debtor
|