连接两个 sql 查询并返回一个响应

问题描述 投票:0回答:1

如何将这两个命令总结为一个命令?

SELECT userName,userId, SUM(amount) AS total_debit FROM debts where buyerId!=userId GROUP BY userName ORDER BY userId
SELECT buyer,userId, SUM(amount) AS total_credit FROM debts where buyerId!=userId GROUP BY buyer ORDER BY userId
sql sqlite sqflite
1个回答
0
投票
SELECT buyer,userId, SUM(amount) AS total_credit FROM debts where buyerId!=userId GROUP BY buyer,userId ORDER BY buyer,userId
© www.soinside.com 2019 - 2024. All rights reserved.