0

I have read various posts about how Group By has changed since 5.7, however, having attempted the various suggested fixes to my query I continue to get the same error:

SELECT list is not in GROUP BY clause and contains nonaggregated column 'mysite.customers.company_name' which is not functionally dependent on columns in GROUP BY clause;

Here is my query:

 return DB::table('quotations')
        ->join('customers', 'customers.id', '=', 'quotations.customer_id')
        ->select('quotations.reference','company_name','customers.lastname1', 'customers.address', 'quotations.*')
        ->where('quotations.status', '=', 'open')
        ->groupBy('quotations.reference')//   THIS CREATES AN ERROR !
        ->orderBy('created_at')
        ->get();

If a company buys 20 things the quote will carry 1 single unique reference plus the company name,lastname etc. However, each row will have the same reference but not the item he bought.

So, when I group by, I am only grouping by the reference, not the product.

So in frustration, I tried the various suggestions for disabling this strict mode, but that did not work either.

Question: What do I do to get my query to work ? Thanks !

Vince
  • 1,405
  • 2
  • 20
  • 33

0 Answers0