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: help me with the query

Re: help me with the query

From: Mladen Gogala <mgogala.SPAM_ME.NOT_at_verizon.net>
Date: Thu, 17 May 2007 15:20:04 GMT
Message-ID: <pan.2007.05.17.15.20.03@verizon.net>


On Thu, 17 May 2007 07:07:41 -0700, maruf.syfullah wrote:

> Your objective

My objective? A bit presumptuous, aren't you? What do I get for reaching "my objective"?

> is to construct a SINGLE QUERY which will produce the
> following output -
>
> employeename | salary | percent
> -------------------|--------|-----------
> a | 2300 | 19.08 b | 1000
> | 16.03 c | 3500 | 11.45 d
> | 3100 | 38.17 e | 2000 | 15.27
> total | 11900 | 100.00
>
>
> The last row of the output indicates the total sum of salaries. The
> column 'percent' indicates the percentage of the associated employees'
> salary out of the total salary.

This is lesson 1 in any SQL course which includes the use of analytic functions. If there is anything simpler, I have yet to see it.

select employeename,salary,ratio_to_report(salary) over () as percentage from table;

Please, read the f@#$ manual before posting. This exact example is in the SQL reference manual under "RATIO_TO_REPORT". I hope that I reached my objective. My further replies to posts like this are likely to include adult language, sex and violence and will, therefore, be rated "R".

-- 
http://www.mladen-gogala.com
Received on Thu May 17 2007 - 10:20:04 CDT

Original text of this message

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