Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: sql question
On Sun, 19 Sep 2004 09:20:02 GMT, "Dave"
<david.sharples3_at_ntlXworld.com> wrote:
>
>"Mirlok" <tima_at_azercell.com> wrote in message
>news:2r501vF167harU1_at_uni-berlin.de...
>> Hi,
>> How can this be rewritten as a single SQL script?
>>
>> de
clare
>> sumtot number;
>> sum1 number;
>> sum2 number;
>> begin
>> select sum(column) into sum1 from table where condition1;
>> select sum(column) into sum2 from table where condition2;
>> sumtot:=sum1-sum2;
>> end;
>>
>> Thank you in advance
>>
>>
>>
>>
>
>select (sum(column) from table where condition1) - (sum(column) from table
>where condition2) from dual;
>
>
Won't work. This will :
select sum1-sum2 from
(select sum(column) as sum1 from table where condition1) ,
(select sum(column) as sum2 from table where condition2) ;
![]() |
![]() |