Subject Re: [firebird-support] SQL - How to ?
Author macma
Michael Vilhelmsen napisaƂ(a):

>
> Hi
> I have a table containing 9 records.
>
> Those are:
>
> Type,Number,Amount
> 0,1200,1111
> 0,1200,2222
> 0,1300,3333
> 0,1300,4444
> 1,1500,5555
> 1,1500,6666
> 1,1600,7777
> 2,1200,8888
> 3,1300,9999
>
> I would like to select those records, but those of type 0 and same
> number should be a SUM(Amount).
> The rest - just as they are.
>
> Result should be
>
> 0,1200,3333
> 0,1300,7777
> 1,1500,5555
> 1,1500,6666
> 1,1600,7777
> 3,1200,8888
> 3,1300,9999
>
> Maybe Am just tired but I can't seem to write the prober SQL.....
>
> Anyone ?
>
> Michael
>
>
Here You go

select Type, Number, sum(Amount) from TABLE
group by Type,Number

Regards
Macma