【发布时间】:2016-07-20 08:45:36
【问题描述】:
我使用了两张表发票和付款。 我尝试生成已付款、到期和未付款状态。
以下是我的查询,这将提供所有发票和总付款。 我如何应用条件来过滤已付、到期、未付。 我不能给付金额 以下为查询成功:
select a.*, sum(b.amount) as paidamount from tbl_invoices a left join tbl_billpayment b on a.invoiceno = b.invoiceno where a.id != '' GROUP BY b.invoiceno ORDER BY a.billdate DESC LIMIT 0,10
这会报错
select a.*, sum(b.amount) as paidamount from tbl_invoices a left join tbl_billpayment b on a.invoiceno = b.invoiceno where a.id != '' and ( paidamount >= a.total)
注意:错误:“where 子句”中的未知列“paidamount”
感谢您的支持
【问题讨论】:
标签: mysql