[ 2.0.0.0]Sum on a calculated field

Posts   
 
    
Xavier
User
Posts: 7
Joined: 20-Jun-2007
# Posted on: 22-Sep-2008 15:51:29   

Hi,

I am using adapter and I try to do something like this:


select
    sum((FieldTo - FieldFrom) +1) as test
from
    table
group by
    FkField

Can you tell me how to handle this? Thank you for your help.

Xavier

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 22-Sep-2008 15:59:14   

Use GetScalar(), please check Aggregate functions in scalar queries

Xavier
User
Posts: 7
Joined: 20-Jun-2007
# Posted on: 22-Sep-2008 16:03:29   

Hi,

Thanks for your quick reply, I checked that already but I am looking for a collection as a result not a int, decimal, ....

Is it possible?

Thanks

Xavier
User
Posts: 7
Joined: 20-Jun-2007
# Posted on: 22-Sep-2008 16:21:43   

I resolve my problem:

         fields.DefineField(new EntityField2("Quantity",
             ((TableFields.FieldTo - TableFields.SetFrom) + 1), AggregateFunction.Sum), 0);

Thanks for your help

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 22-Sep-2008 16:26:42   

select sum((FieldTo - FieldFrom) +1) as test from table group by FkField

But the above query can't result in a collection.

Anyway, glad you have worked it out.