I'm trying to select all the invoices from a table all with the associated data. This is the SQL I currently have:select invoices.invoice_id, projects.project_id, name, stage_name, sum(qty * invoice_items.cost) as net_value from invoices inner join invoice_items on (invoices.invoice_id = invoice_items.invoice_id) inner join projects on (projects.project_id = invoices.project_id) inner join sites on (sites.site_id = projects.project_id) inner join clients on (clients.client_id = sites.client_id) inner join invoice_stages on (invoice_stages.stage_id = invoices.stage_id) where invoices.invoice_id is not null group by invoices.invoice_id, projects.project_id, name, stage_name
The above only outputs those invoices where the project_id is 1 (I'm assuming that it's actually using the group_by project_id and then using the first found project_id).Can someone point me at the issue with the above and how to rectify it to make it output every invoice regardless of the project_id?Many thanks in advance,Rich