tags:

views:

144

answers:

2

Hi, 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

A: 

Are you using SubSonic 3.0.0.3 or 2.2?

If you're using 2.2, then I don't think you can do it. I'm unsure about 3.0.

Jim W
I am using subsonic 2.2, i think that it will be posseble by SubSonic 3 if using the Linq , but the problem with Linq of Framework 3.5 that you can not execute a data set or data view and if you want to change the format of date column for example you will get in the end to Anonymous Type collection so there is no simple way to bind it to data view.So you are saying Subsonic Dose not have a magic trike to do the "having".Thanks for your time.
TheGodfather
I'm not 100% sure, but I've done a bunch of aggregates with SubSonic 2.2 and I don't remember having a "having". You should double check with the docs just to make sure.
Jim W
+3  A: 

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"

BlackMael
It did the work thanks man
TheGodfather