我希望显示所有待处理发票的详细信息以及一个显示特定客户的待处理发票总数的列,但我无法找到一种方法来做同样的事情。这是我正在尝试做的事情:
+----------+------------+---------------+---------------+
| Customer | Invoice No | Peding Amount | Total Pending |
+----------+------------+---------------+---------------+
| A | 1 | 10 | 1110 |
| B | 2 | 100 | 110 |
| C | 3 | 1000 | 3020 |
| A | 4 | 1000 | 1110 |
| A | 5 | 100 | 1110 |
| B | 6 | 10 | 110 |
| C | 7 | 2000 | 3020 |
| C | 8 | 20 | 3020 |
+----------+------------+---------------+---------------+
现在我想通知该表只有前 3 列,但我需要添加第 4 列,但我无法找到根据客户求和的方法。
这是我尝试使用的代码,但我得到了某种语法。
select
`tabSales Invoice`.`posting_date` as "Invoice Date:Date:80",
`tabSales Invoice`.`due_date` as "Due Date:Date:80",
`tabSales Invoice`.`name` as "Invoice No:Link/Sales Invoice:120",
`tabSales Invoice`.`customer` as "Customer:Link/Customer:180",
`tabSales Invoice`.`grand_total` as "Total:Currency:140",
`tabSales Invoice`.`outstanding_amount` as "Pending:Currency:140",
datediff(curdate(),`tabSales Invoice`.`posting_date`) as "Over By Invoice Date:Float:80",
datediff(curdate(),`tabSales Invoice`.`due_date`) as "Over By Due Date:Float:80",
`tabSales Invoice`.`debit_to` as "Customer Account:Link/Account:200"
from
`tabSales Invoice`
where
`tabSales Invoice`.`docstatus` = 1
and `tabSales Invoice`.`outstanding_amount` > 0.005
Inner join(
Select
`tabSales Invoice`.`customer`,
SUM(`tabSales Invoice`.`outstanding_amount`) AS "Total Pending::180"
from
`tabSales Invoice`
Group By
`tabSales Invoice`.`customer`)
`tabSales Invoice` ON `tabSales Invoice`.`customer`