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

Home -> Community -> Usenet -> c.d.o.misc -> Re: sql query for horizontal and vertical sum.

Re: sql query for horizontal and vertical sum.

From: Frank van Bortel <fvanbortel_at_netscape.net>
Date: Sat, 08 Jan 2005 16:24:54 +0100
Message-ID: <crotug$93n$1@news1.zwoll1.ov.home.nl>


ashok wrote:
> Dear all,
> I am using the emp like table from the oracle.
> MY requirement is
> 1.
> to calculate the total sum of sal+comm;
> select sal+comm from emp; would only print the results where comm in
> not NULL but I want to display the sal + comm for NULL comm values as
> well (i.e only sal will be displayed for sal + comm ) along with the
> other sal + comm values.
>
> 2.
> alongwith the above requirement , i want the total of only all the sal
> fields (total sal)and total of all the comm fields(total comm).i.e
> vertical total of sal and comm fields.
>
> I have just avergae knowledge of oracle and tried my best to write the
> above related queries but couldn't got the appropriate results.

No, you don't even have a beginner's level understanding of SQL.
> I request you to kindly help me as I am totally stuck now..
>

As this is homework or training, I will not reveal the solution, just give pointers.
1) Check the manual(s) for a function that will alter

   a column value, if that column contains a nullvalue. 2) Not sure I understand that; sum(sal) will do that, and

   you have tried that, as I understand it.

-- 
Regards,
Frank van Bortel
Received on Sat Jan 08 2005 - 09:24:54 CST

Original text of this message

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