我有两个表 sales 和 customers 来自第一个表我想将两列 recived_amount 和 bill_amount 相加并减去它们,然后还想得到 customer_id
从第二张桌子我只想得到 Customer_name
我试过了
SELECT Customer_details.CUS_name,
SUM(SALES.Bill_Amount) - SUM(SALES.Recived_Amount),
Customer_details.Cus_id
from sales
INNER JOIN Customer_details
ON Customer_details.Cus_id=sales.Cus_id
where SALES.Cus_id = 1 order BY Cus_id