Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: sql question

Re: sql question

From: <Kenneth>
Date: Sun, 19 Sep 2004 19:45:20 GMT
Message-ID: <414de0bb.245234@news.inet.tele.dk>


On Sun, 19 Sep 2004 17:43:34 GMT, "VC" <boston103_at_hotmail.com> wrote:

>Before claiming 'it won't work', why don't you check ???
>
>Both versions will.

I did check. Unlike *you*, cause if you had checked you would have found the following :

SQL> create table table1 (col number(1));

Table created

SQL> select (sum(col) from table1 where col > 4) - (sum(col) from table1
where col> 5) from dual;

ORA-00907: missing right parenthesis

>
>
><Kenneth Koenraadt> wrote in message
>news:414db170.650531_at_news.inet.tele.dk...
>> 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) ;
>>
>> - Kenneth Koenraadt
>>
>>
>>
>>
>>
>
>
Received on Sun Sep 19 2004 - 14:45:20 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US