I'm trying to do the following query:
pl_invoices.invoice_id = pl_invoice_articles.invoice_article_invoice_id
pl_invoices.invoice_amount_paid = SUM(pl_invoice_articles.invoice_article_price)
) as 'Aantal Betaald'
Use having clause instead of where
SELECT cnt as 'Aantal Betaald' from ( SELECT COUNT(*) AS CNT, invoice_amount_paid FROM pl_invoices pl JOIN pl_invoice_articles pla ON pl.invoice_id = pla.invoice_article_invoice_id having pl.invoice_amount_paid = SUM(pla.invoice_article_price) ) tt ;