Multi-level grouping

I have a database from which I need to extract about 15 fields (some as a result of joins), but only need to group hierarchically on 2, and then sort on a couple other fields.

The only way I've found is to group by all 15 fields... and the result is REALLY slow to run (surprise...)
What I am looking for is a way that I can group on each level, so I can iterate over the multiple groupings, but still pick out the non-grouped fields. So far, I always seem to hit one issue or another, eg scope.

Any pointers welcome, (preferably in query syntax)


  • edited September 2020

    You should probably post a question on StackOverflow. Telling us what querying library / method you are using (e.g. LINQ to SQL / EF / EF Core 2.0 / EF Core 2.1 / EF Core 3.x) and some sample C# Types would help too.

Sign In or Register to comment.