Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: help me with the query
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.comReceived on Thu May 17 2007 - 10:20:04 CDT
![]() |
![]() |