Hi! I've a sql request in Laravel, but I didn't need all columns in GroupBy. If I do this, I get an Error. But it works on the DB direct. Where is my mistake in Laravel?
Laravel (not Working!):
$testMinMax = (new \App\Test) ->select(DB::raw('bookmaker_id, fixture_id, market_id, test_label, max(test_value) as max_test')) ->where('market_id', 1) ->whereIn('fixture_id', $fixtures->pluck('id')->toArray()) ->groupBy('fixture_id', 'market_id', 'test_label') ->get();
Then I add bookmaker_id to groupBy and all is fine, so I get the querie in Telescope. I did remove the bookmaker again and tried the SQL Request on the DB, it works. Why?
select bookmaker_id, fixture_id, market_id, test_label, max(test_value) as max_test from `test` where `market_id` = 1 and `fixture_id` in (........) group by `fixture_id`, `market_id`, `test_label`