Skip to content

Mixing SUM with other columns #203

Closed
@Sharparam

Description

@Sharparam

It doesn't seem possible to have a SUM in a SELECT column list together with other columns (unless you hardcode it with SelectRaw), is this correct?

Consider this query:

SELECT GroupId, SUM(Age)
FROM People
GROUP BY GroupId

I can only find AsSum on the query object, but this makes it only select a SUM, and discards any other columns that have been selected with Select().

It also requires an alias on the SUM, but that's a minor thing.

Here's an example in MySQL.

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