Задать вопрос
  • Как получать ниже указанный результат?

    @Ram1979 Автор вопроса
    Проверял вот так
    ->select(DB::raw('count(*) as count, group_id, coeff_id, coeff'))
    ->groupBy('group_id')
    ->get()->toArray();
    получаю: "SQLSTATE [42000]: синтаксическая ошибка или нарушение прав доступа: 1055 'test.posts.coeff_id' отсутствует в GROUP BY (SQL: выберите count (*) как count, group_id, coeff_id, coeff из группы` posts` по `group_id `)

    ->select(DB::raw('count(*) as count', 'group_id', 'coeff_id','coeff'))
    [0] => stdClass Object
    (
    [count] => 1
    )

    [1] => stdClass Object
    (
    [count] => 1
    )

    ->select(DB::raw('count(*) as count', 'group_id', 'coeff_id','coeff'))
    ->groupBy('group_id','coeff_id','coeff')
    ->get()->toArray();

    [0] => stdClass Object
    (
    [count] => 1
    )

    [1] => stdClass Object
    (
    [count] => 1

    ->select(DB::raw('count(*) as count, group_id, coeff_id, coeff'))
    ->groupBy('group_id')
    ->get()->toArray();

    [0] => stdClass Object
    (
    [count] => 5
    )

    [1] => stdClass Object
    (
    [count] => 5
    )