Skip to content

Illuminate\Database\Query\Builder->count() not working as expected on a query using group by #2761

Closed
@MarkVaughn

Description

@MarkVaughn

When I create a table that uses joins and group bys the count() function does not return the number of results, here's an example from the sql

select count(*) as aggregate from `account` left join `location` on `account`.`id` = `location`.`account_id` where `account`.`deleted_at` is null group by `account`.`id`

Instead of the number of results it shows the number of locations associated with an account (from the group by)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions