Skip to content
Advertisement

Error 1140 using the query builder of Laravel and count aggregate

I want to do the following SQL query using the Laravel query builder:

I tried with the following code but it doesn’t work correctly:

I reiceived the following error:

Can help?

Advertisement

Answer

Aggregate functions like sum,count,min,max,avg when selected with other columns it must have a groupBy clause for one of these column.

your query have two columns 'source' & 'customer_id' you must add a group by to both of them:

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement