Skip to content

Latest commit

 

History

History
31 lines (24 loc) · 559 Bytes

group.md

File metadata and controls

31 lines (24 loc) · 559 Bytes

Grouping

GroupBy

//:playground
var query = new Query("Comments")
                .Select("PostId")
                .SelectRaw("count(1) as count")
                .GroupBy("PostId");
SELECT [PostId], count(1) as count FROM [Comments] GROUP BY [PostId]

GroupByRaw

//:playground
var query = new Query("Companies")
    .Select("Profit")
    .SelectRaw("COUNT(*) as count")
    .GroupByRaw("Profit WITH ROLLUP");

In PostgreSql

SELECT "Profit", COUNT(*) as count FROM "Companies" GROUP BY Profit WITH ROLLUP