Subject RE: [firebird-support] Simple sql query question
Author Alan McDonald
> Hello,
>
> I am wondering is it possible to get this result without writting UDF.
>
> There is a table:
> Field1 Field2
> ---------------
> 1 2
> 1 1
> 1 3
> 2 4
> 2 1
> 2 3
> ---------------
>
> I need to get in one recod sum() of Field2 according to Field1. Wanted
> result:
>
> ResField1 ResField2
> ---------------------
> 6 8
> ---------------------
>
> 6 = 2+1+3 (Field1 = 1)
> 8 = 4+1+3 (Field2 = 2)
>

You don't need a UDF - just write yourself an SSP.
Doa FOR SELECT INTO loop ordering Field1, then add up the values of Field2
while the Field1 value remains the same, then move on... SUSPENDing the
results as you go
Alan