SELECT
supplier_invoice.supplier_invoiceid,
supplier_invoice.supplier_invoiceid,
supplier.company_name as supplier,
supplier_invoice.`date`,
supplier_invoice.recieved_amount,
format(sum((supplier_invoice_lines.qty*supplier_invoice_lines.cost_price_excluding_vat)),2) as Sup_inv_value_excl,
supplier_invoice.processed_transaction as posted
FROM
supplier_invoice
Left Join supplier ON supplier.supplierid = supplier_invoice.supplierid
Left Join supplier_invoice_lines ON supplier_invoice_lines.supplier_invoiceid = supplier_invoice.supplier_invoiceid
group by supplier_invoice.supplier_invoiceid