I wanted to know how often an invoiceID appears among the invoiceLines that this invoice has. SO for example
+++++++++++++++++++++++++++++++++ + invoiceID+ COUNT(invoiceLines)+ +++++++++++++++++++++++++++++++++ + 1 + 10 + +++++++++++++++++++++++++++++++++ + 2 + 17 + +++++++++++++++++++++++++++++++++ + 3 + 5 + +++++++++++++++++++++++++++++++++ etc.
My current query looks like this:
select DISTINCT invoice.invoiceID, COUNT(invoiceLine.invoiceLineID) from invoice join invoiceLine on invoiceLine.fk_invoiceID = invoice.invoiceID; Though this won't work, as I'm selecting a none aggregated value and an aggregated value. Hence the error message:
In aggregated query without GROUP BY, expression #1 of SELECT list contains nonaggregated column 'wms_new.invoice.invoiceID'; this is incompatible with sql_mode=only_full_group_by Does anybody know how to pull off something like this without disabling "sql_mode=only_fill_group_by"
DISTINCTand addGROUP BY invoice.invoiceIDto the end of your query.