Subsonic Aggregation Constraint (“Having”)

subsonic

I want to no if there any way to add an "Having" constrain to an aggregation select?
Example: if i need all sales sum by date having the sales sum > 1000.

Best Regards,
TheGodfather

Best Answer

SubSonic does have a "having" but you don't explicitly state it.

It is determined from you selecting an Aggregate and adding the Aggregate to the Where clause.

For example (paraphrased from SubSonic AggregateTests.cs)

        SubSonic.SqlQuery q = new
            Select(Aggregate.GroupBy("ProductID"), Aggregate.Avg("UnitPrice"))
            .From("Order Details")
            .Where(Aggregate.Avg("UnitPrice"))
            .IsGreaterThan(50);

The SubSonic query above will create a SQL statement with a "HAVING AVG(UnitPrice) > 50"