Subject | Re: [firebird-support] SQL - How to ? |
---|---|
Author | Milan Babuskov |
Post date | 2004-10-07T12:36:20Z |
Michael Vilhelmsen wrote:
from table
where type=0
group by type, number
union all
select type, number, amount
from table
where type <> 0;
Enjoy :)
--
Milan Babuskov
http://fbexport.sourceforge.net
http://www.flamerobin.org
> Type,Number,Amountselect type, number, sum(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.....
from table
where type=0
group by type, number
union all
select type, number, amount
from table
where type <> 0;
Enjoy :)
--
Milan Babuskov
http://fbexport.sourceforge.net
http://www.flamerobin.org