Ugent: Regarding Oracle 10g Analytic functions

Hi,
EMP TABLE:
EMPNO     ENAME          JOB          MGR          HIREDATE          SAL          COMM     DEPTNO
==================================================================
7369          SMITH          CLERK          7902          12/17/1980     800                    20
7499          ALLEN          SALESMAN          7698          2/20/1981          1600          300          30
7521          WARD          SALESMAN          7698          2/22/1981          1250          500          30
7566          JONES          MANAGER          7839          4/2/1981          2975                    20
7654          MARTIN          SALESMAN          7698          9/28/1981          1250          1400          30
7698          BLAKE          MANAGER          7839          5/1/1981          2850                    30
7782          CLARK          MANAGER          7839          6/9/1981          2450                    
7788          SCOTT          ANALYST          7566          12/9/1982          3000                    20
7839          KING          PRESIDENT                    11/17/1981     5000                    
7844          TURNER          SALESMAN          7698          9/8/1981          1500          0          30
7876          ADAMS          CLERK          7788          1/12/1983          1100                    20
7900          JAMES          CLERK          7698          12/3/1981          950                    30
7902          FORD          ANALYST          7566          12/3/1981          3000                    20
7934          MILLER          CLERK          7782          1/23/1982          1300                    
================================================================
I would like the output group by manger and the employees under that manager using analytic functions.
Output should look like:
ManagerName EMPNAME
==========================================================
KING JONES,BLAKE,CLARK
JONES SCOTT,FORD
BLAKE ALLEN,WARD,MARTIN,TURNER,JAMES
CLARK MILLER
FORD SMITH
SCOTT ADAMS
Also I would like to run this query in unix shell script in order to create a folder structure like this:
Root Folder: King -> Jones -> SCOTT -> ADAMS
-> FORD -> SMITH
-> BLAKE -> ALLEN
-> WARD
-> MARTIN
-> TURNER
-> JAMES
-> CLARK -> MILLER
On a total 14 folders should be created.
Thanks in Advance
G.Vamsi Krishna
Edited by: user10733211 on Apr 20, 2009 11:30 PM

user10633982 wrote:
hey guys can you please give your personal opinions and remarks out of this thread.
this thread is supposed to be solving query and not for chit chattingNot chit chatting and not just personal opinions, just letting you know how it works around here...
Urgent is it?
Why? Have you forgotten to do your coursework and you'll get thrown off your course if you don't hand it in today?
What makes you believe that your request for help is more important than someone else who has requested help? It's very rude to assume you are more important than somebody else, and I'm sure they would like an answer to their issue as soon as they can get one too, but they've generally been polite and not demanded that it is urgent.
Also, you assume that people giving answers are all sitting here just waiting to answer your question for you. That's not so. We're all volunteers with our own jobs to do. How dare you presume to demand our attention with urgency.
If you want help and you want it answering quickly you simply just put your issue forward and provide as much valuable information as possible.
You will find if you post on here demanding your post is urgent then most people will just ignore it, some will tell you to get lost, and some will explain to you why you shouldn't post "urgent" requests. Occasionally you may find somebody who's got nothing better to do who will actually provide you with an answer, but you really are limiting your options by not asking properly.
How can something being run against the SCOTT schema be something that is "urgent"?
For the first part of your enquiry:
SQL> ed
Wrote file afiedt.buf
  1  with emps as (select ename, mgr, row_number() over (partition by mgr order by ename) as rn from emp)
  2  select ename as managername
  3        ,(select ltrim(sys_connect_by_path(emps.ename,','),',')
  4          from   emps
  5          where emps.mgr = emp.empno
  6          and connect_by_isleaf = 1
  7          connect by rn = prior rn + 1 and mgr = prior mgr
  8          start with rn = 1
  9         ) as empname
10  from emp
11* where empno in (select mgr from emp)
SQL> /
MANAGERNAM EMPNAME
JONES      FORD,SCOTT
BLAKE      ALLEN,JAMES,MARTIN,TURNER,WARD
CLARK      MILLER
SCOTT      ADAMS
KING       BLAKE,CLARK,JONES
FORD       SMITH
6 rows selected.
SQL>As for using that output in a unix shell script to create directory structures you should consider asking in a unix forum.

Similar Messages

  • Grouping error in Oracle's analytic function  PERCENTILE_CONT()

    Hi,
    I have a question regarding the usage of Oracle's analytic function PERCENTILE_CONT(). The underlying time data in the table is of hourly granularity and I want to fetch average, peak values for the day along with 80th percentile for that day. For the sake of clarification I am only posting relevant portion of the query.
    Any idea how to rewrite the query and achieve the same objective?
    SELECT   TRUNC (sdd.ts) AS ts,
             max(sdd.maxvalue) AS max_value, avg(sdd.avgvalue) AS avg_value,
             PERCENTILE_CONT(0.80) WITHIN GROUP (ORDER BY  sdd.avgvalue ASC) OVER (PARTITION BY pm.sysid,trunc(sdd.ts)) as Percentile_Cont_AVG
    FROM     XYZ
    WHERE
              XYZ
    GROUP BY  TRUNC (sdd.ts)  
    ORDER BY  TRUNC (sdd.ts)
    Oracle Error:
    ERROR at line 5:
    ORA-00979: not a GROUP BY expression

    You probably mixed up the aggregate and analytical versin of PERCENTILE_CONT.
    The below should work, but i dont know if it produces the desireed results.
    SELECT   TRUNC (sdd.ts) AS ts,
             max(sdd.maxvalue) AS max_value, avg(sdd.avgvalue) AS avg_value,
             PERCENTILE_CONT(0.80) WITHIN GROUP (ORDER BY  sdd.avgvalue ASC)  as Percentile_Cont_AVG
    FROM     XYZ
    sorry, what is this where clause for??
    WHERE
              XYZ
    GROUP BY  TRUNC (sdd.ts)  
    ORDER BY  TRUNC (sdd.ts) Edited by: chris227 on 26.03.2013 05:45

  • Oracle 10g Analytic Workspace Manager 10.1.0.4( where to download?)

    Guys,
    I'm looking for a link to install Oracle 10g Analytic Workspace Manager 10.1.0.4.
    Can someone help me with the link?.
    Thanks,
    Bhagat

    Thank you, we have this :
    SELECT COMP_NAME, VERSION, STATUS FROM DBA_REGISTRY WHERE COMP_NAME LIKE '%OLAP%';
    COMP_NAME VERSION STATUS
    OLAP Analytic Workspace 10.2.0.1.0 VALID
    Oracle OLAP API 10.2.0.1.0 VALID
    OLAP Catalog 10.2.0.1.0 VALID
    Is Analytic Workspace Manager installed ? How to know its version ?
    Thank you.

  • Regarding Oracle 10g Express Edition

    Dear Friends,
    I'm very beginner to Oracle database. I worked in SQL Server.
    Here I have downloaded and intalled Oracle 10g Express Edition for development.
    1. How do I create database in Oracle 10g Express Edition?
    2. How do I attach an existing database?
    Please help me.
    Thanks in advance.
    Regards,
    Sathish

    Hi,
    ORACLE is different from SQL Server. Forget about SQL Server for a while.
    1. How do I create database in Oracle 10g Express Edition?Refer to :http://st-curriculum.oracle.com/tutorial/DBXETutorial/index.htm
    2. How do I attach an existing database?As you perform in Sql Server, it won't work in oracle. It's different. I request to understand oracle architecture and basic Administration and once you familar with those things then can understand how to perform activity's on DB.
    - Pavan Kumar N
    Oracle 9i/10g - OCP
    http://oracleinternals.blogspot.com/

  • Query  regarding oracle 10g connection in Visual Studio 2005

    Hi ,
    I am having visual studio 2005 installed in my system . when i am adding oracle database connection it is displaying that "use this connection for oracle 7 ,8, 9i versions ..i want to connect oracle 10g database in visual studio 2005. plz tell me how to do that?

    looks like u'r try connecting to oracle using server explorer, just hit OK an then fill in your server name, userid and password.
    server name might be SID defined in your tnsnames.ora, or in the form of //<machine_name>/<service_name>

  • Regarding Oracle 10G Developer Suite On Oracle 9i R2

    Actually i am new to oracle *9i R2* because i worked on Oracle 7 in that i was getting by default forms and reports will be installed. after inquiring with my friends they said that in oracle *9i R2* there wont be forms and reports installed for that you have to install Oracle 10G Developer Suite. but i am having a doubt that weather both can be installed on the same machine in the same operating system.

    Yes we can use 2 databases on same machine on same operating system but u need to use different Oracle Homes for each version. But u can't ran Form 10g wid Oracle 9i database. You need to use only 10G forms Reports wid 10G Database.
    Thanks
    Nilesh
    www.erporacleapps.blogspot.com

  • Regarding ORacle 10g installation

    Hi,
    I am getting this error while installing oracle 10g database in windows machine.
    i am getting this error "nmesrvc.exe".
    Thanks in advance.

    What error are you getting? "nmservc.exe" looks like an executable file name.
    FYI, if you're installing Oracle 10g on a laptop or another machine whose IP address might change you'll need to install a loopback adaptor first. The loopback adaptor prevents problems with the database and related components should the IP address change - I failed to do this on my laptop a few years back and used it in a hotel to check my email address. Everything oracle-related broke. I managed to fix the database and Apex, but never did get OEM or iSQLPLUS to work again. There are instructions on installing a loopback adaptor on line and (I think) here on OTN; you should get a warning about this when you try to install.

  • Regarding oracle 10g express edition login problem

    Hi all,
    This morning, i downloaded 10g oracle express editon from oracle.com.. I installed sucessfully. i am able to login from the command line sucessfully..
    But when i am clicking on Goto database home page it is connecting http://127.0.0.1:8080/apex and it says page can not be displayed .. can anyone help me please its urgent
    Ganesh

    Hi Ganesh
    Try to chang your port - it worked on my installation see the following link:
    http://www.oracle.com/technology/tech/linux/install/files/el5_11g_sqldev_apex.txt
    Additionnally do Perform the following in sqlplus logged on as sys:
    show parameter dispatchers
    This should return something like:
    NAME TYPE VALUE
    dispatchers string (PROTOCOL=TCP) (SERVICE=<sid>XDB)
    max_dispatchers integer
    When in your case the value of dispatchers is empty, you have to do the
    following:
    Define an entry in the init.ora (<sid> must be replaced by the sid of your 11.1.0.6db):
    dispatchers="(PROTOCOL=TCP)(SERVICE=<sid>XDB)"
    for example:
    dispatchers="(PROTOCOL=TCP)(SERVICE=v111XDB)"
    After the change you have to restart the database.

  • Regarding Oracle 10g Grid Control Enterprise Manager

    Hi Friends,
    the file at http://www.oracle.com/technology/software/products/oem/htdocs/winsoft10g.html
    Named B30800-01.zip is having a problem.
    As I had downloaded the file with the (download manager and Directly also), but after downloading file size is been matching and there was no error with the download of the file.
    Downloaded File Size = 1729778063 Jul 13 07:44 b30800_0.zip
    But at the time of getting extract the file has been given many errors.
    Can anyone tell me what should I do?
    As I had tried to send a mail with extraction report to Oracle Corporation email id but I got a failure Delivery.
    Can anyone give me the email id of oracle corporation where I can get some help from Oracle Corporation.
    Thanks in Advance
    Regards,
    Bhavik Fuletra

    Hi,
    Dear lavaprasadkafle,
    Size and size on disk usually differs
    The Size is the real size of the file,
    The file system stores data in clusters of certain size (Usually 4k bytes in NTFS, 8k or 16k in FAT32), so if you have a file with size 250 bytes on NTFS 4k, Size on disk will be 4 k (4096 bytes), with FAT32 at cluster size 16, the size on disk will be 16384 bytes!
    For the file you mentioned, I guess that it is stored on FAT32 partition with 16k cluster size, just calculate it as previously done, you will find where 11889 bytes came from.
    On the other hand, to make sure that the zip file is downloaded correctly, just open and test it with any archive tool that have test. or you can use MD5 or any other hashing check.
    Regards

  • How to use aggregate functions into Analytical functions

    Can we use aggregate functions into analytical functions?
    Please provide one example.
    Smiles.

    HI Learner6
    for information:
    Aggregate Functions
    Analytic Functions
    for practic:
    ORACLE-BASE - Analytic Functions
    Thank you

  • Oracle 10g SQL

    Hi ,
    I want some information regarding Oracle 10g SQL Exam.Please provide any dumps,links,books or any other related information.
    Thanks in Advance
    Laxman

    login to otn.oracle.com to find more information on exams
    underline Steps to Become Oracle Certified_underline_
    http://education.oracle.com/pls/web_prod-plq-dad/db_pages.getpage?page_id=50#1
    If you are from India, below is the contact info
    Bangalore 080 41084657
    Chennai 044-66346114
    Delhi 011-46509015
    Hyderabad 040-66397157
    Kolkata 033-66162000
    Mumbai 022-67711214
    Ahemdabad 079-40024246
    Pune 020-66321002
    Thank You

  • Oracle 10g on VMWare

    I have not been able to find a satisfactory answer regarding Oracle 10g on VMWare. On one page, Oracle states that "Oracle will not support production deployments of Oracle software on VMware" (http://www.oracle.com/technology/tech/linux/vmware/cookbook/index.html). However, the Metalink article it references states "Oracle will provide support of the Oracle Stack on VMware. If a problem is investigated where Oracle software gives a problem specifically when running on a VMware virtual machine, and it can be reproduced on a physical PC, a bug will be submitted to development for resolution. Any issues which are VMware
    specific will be referred back to VMware for support."
    Now I'm stuck in a difficult position: I have a production database installed on a VMware device that is seriously sucking wind (mostly related to disk I/O and swap, either the VMware device or the ESX server it's running on) and I have contradictory information from Oracle. Does anyone have any insight into a formal position from Oracle?
    Without a definitive answer, I need to figure out a way to tune what I have to squeeze every last drop of performance from the VMware device. I am running Oracle 10gR2 in 9.2.0.6 compatibility mode. I am running RedHat Enterprise Linux 3 ES, update 7. The VMware device has 2 CPUs and 2 GB of RAM (the most this version of ESX can provide is ~3.5 GB but I start running into issues because the ESX server is oversubscribed at that amount of RAM). The database is doing mostly OLTP and is approximately 150 GB in size.
    Any assistance / guidance is greatly appreciated.

    I
    start running into issues because the ESX server is
    oversubscribed at that amount of RAM). The database
    is doing mostly OLTP and is approximately 150 GB in
    size.Do you think being oversubscribed on the memory might be a factor to why you are seeing high I/O and swapping?
    What they stating is that Oracle will support the product in VMWare providing the problem can be reproduced on a physical machine. Oracle is not alone in this regard, many other companies are taking the same position.

  • Oracle Analytic function tuning

    Hi all,
    Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bi
    PL/SQL Release 10.2.0.3.0 - Production
    CORE 10.2.0.3.0 Production
    TNS for IBM/AIX RISC System/6000: Version 10.2.0.3.0 - Productio
    NLSRTL Version 10.2.0.3.0 - Production
    I have a query which has analytic function uses large space on temporary tablespace resulting in direct path temp read and direct path temp write wait events taking too much time. Is there any way to tune such query?
    Thanks in advance.

    user9074365 wrote:
    Hi all,
    Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bi
    PL/SQL Release 10.2.0.3.0 - Production
    CORE 10.2.0.3.0 Production
    TNS for IBM/AIX RISC System/6000: Version 10.2.0.3.0 - Productio
    NLSRTL Version 10.2.0.3.0 - Production
    I have a query which has analytic function uses large space on temporary tablespace resulting in direct path temp read and direct path temp write wait events taking too much time. Is there any way to tune such query?
    With your version of Oracle, and high-volumes of data going through analytic function, it's likely that this blog note applies. You may need an upgrade or special patch. http://jonathanlewis.wordpress.com/2009/09/07/analytic-agony/
    Regards
    Jonathan Lewis

  • Pivot function in Oracle 10g???

    Hello everybody,
    at the beginning of the week I had a simple problem (I thought that...), but now after trying and trying, I can't find a solution for it. First of all I'm working on Oracle 10g with the version 10.2.0.4.0. I can't change the version, it's standard in the whole company...
    At the beginning I have a table like the following one, but please note, that the compartment, the type and the amount are flexible and can change at any time:
    comp type amount
    a1 6280 10
    a2 6280 20
    a2 4810 15
    a2 1147 12
    a3 6280 33
    Now I want the table to look like this:
    a1 a2 a3
    1147 0 12 0
    4810 0 15 0
    6280 10 20 33
    A simple question in Excel for example, I just use the pivot function and have it fixed within 10seconds. But how can I do sth. like this in Oracle with simple SQL? Or it can be PL/SQL too, cause I will use this in an APEX application.
    Can you please give me a hint or a solution? But as stated before a1, a2, a3 are just examples it is possible that tomorrow a4, a5 and so on are coming. If it is necessary I can also create additional tables and views of course!
    Thanks for your help!
    Regards
    hoge

    Hi Hoge!
    Here is your solution:
    SELECT TYPE,
           sum(a1) AS a1,
           sum(a2) AS a2,
           sum(a3) AS a3
      FROM (SELECT TYPE,
                   decode(comp, 'a1', amount, 0) AS a1,
                   decode(comp, 'a2', amount, 0) AS a2,
                   decode(comp, 'a3', amount, 0) AS a3
              FROM test)
      GROUP BY TYPE
      ORDER BY TYPE; And here is my test case setup:
    CREATE TABLE test
        (comp VARCHAR2(255),
         TYPE NUMBER,
         amount NUMBER);
    INSERT INTO test(comp, TYPE, amount) VALUES('a1', 6280, 10);
    INSERT INTO test(comp, TYPE, amount) VALUES('a2', 6280, 20);
    INSERT INTO test(comp, TYPE, amount) VALUES('a2', 4810, 15);
    INSERT INTO test(comp, TYPE, amount) VALUES('a2', 1147, 12);
    INSERT INTO test(comp, TYPE, amount) VALUES('a3', 6280, 33);
    commit;Best regards,
    Matt

  • Oracle 10g trigger to pass variable to xmltype.existsnode() function

    Hi all,
    Could anyone please help me on this? It is kind of urgent.
    I created a trigger below, it compiled successfully, but when I tried to insert a xml document into oracle 10g db, I got error message says:
    550- Error Response
    ORA-00604: error occurred at recursive SQL level 1
    ORA-30625: method dispatch on NULL SELF argument is disallowed
    ORA-06512: at "CONTENTDB.VALIDATE_LINK", line 11
    ORA-04088: error during execution of trigger 'CONTENTDB.VALIDATE_LINK'
    550 End Error Response
    My trigger is:
    CREATE OR REPLACE TRIGGER VALIDATE_LINK
    BEFORE insert on TABLE_LINK
    FOR each row
    DECLARE
    v_key VARCHAR2(1000);
    v_count NUMBER(5);
    xmldata XMLType;
    begin
    xmldata := :new.sys_nc_rowinfo$;
    IF xmldata.existsnode('/link/key') = 1 THEN
    v_key := xmldata.extract('/link/@key').getStringVal();
    select count(*) into v_count from table_link WHERE (existsNode(object_value,'/link[key=v_key]') = 1 )
    and (existsNode(object_value,'/link/publishingElements[TestingFlag="true"]') = 1);
    if (v_count >= 1) then
    raise_application_error (-20001, 'TestingFlag can only have one true value.');
    end if;
    end if;
    end;
    I have questions regarding above trigger:
    1) it seems extract() doesn't work in statement below: v_key := xmldata.extract('/link/@key').getStringVal();
    2) can I pass a variable v_key into xmltype.existsnode() function? if yes, what is the right format to do so?
    Thanks a lot.
    Honson

    Hi Mark,
    Thanks for your comments, I have added checking for xmltype object is not null logic. and my initial problem was fixed, the only last problem I am having now is xmltype.extract().
    CREATE OR REPLACE TRIGGER VALIDATE_LINK
    BEFORE insert on table_LINK
    FOR each row
    DECLARE
    v_key VARCHAR2(4000);
    v_count NUMBER(5);
    xmldata XMLType;
    v_tmp VARCHAR2(4000);
    begin
    xmldata := :new.sys_nc_rowinfo$;
    if (xmldata is not null) then
    IF xmldata.existsnode('/link/key') = 1 THEN
    v_key := xmldata.extract('/link/key').getStringVal();
    v_tmp := '/link[key=' || v_key || ']';
    select count(*) into v_count from cibc_link WHERE (existsNode(object_value,v_tmp) = 1 )
    and (existsNode(object_value,'/link/publishingElements[TestingFlag="true"]') = 1);
    if (v_count >= 1) then
    raise_application_error (-20001, 'TestingFlag can only have one true value.');
    end if;
    end if;
    end if;
    end;
    I am expecting this statement:
    v_key := xmldata.extract('/link/key').getStringVal();
    return v_key := content.link.viewPrintableVISACreditCard
    but now it always returns like this:
    v_key := <key>content.link.viewPrintableVISACreditCard</key>
    I don't want the xml tag <key></key> returned by extract().getStringVal() function.
    Could you or anyone please help?
    Thanks.
    Honson

Maybe you are looking for

  • How do I transfer iTunes balance from one account to another

    I accidently put the wifes gift card into my account when she wanted me to download some songs for her.  Now she wants the remaining balance in her account, how do I move it over?

  • Home Sharing freezes

    When I select Home Sharing on my iPhone 5 it freezes when the progress circle is about at the half way point (semi-circle).  Does Home Sharing have any limitations regarding how much music can be shared between devices?  My iTunes library has over 67

  • Printing Issue on a MacPro and Lion

    When using any Apple prgram, such as Pages, Numbers, Text, etc. and I try to print to my laser printer from my MacPro I get an error and the following message: You don't have permission to write to the folder that the file "Untitled" is in. You can d

  • How to set default number format for whole app

    Hi! I have a bunch of View Objects and I have to set the format for each attribute of type number. I've tried using MyAtt_FMT_FORMAT=#,##0.00 MaAtt_FMT_FORMATTER=oracle.jbo.format.DefaultNumberFormatter on just a couple of attributes and it works OK.

  • Hide some columns in alv if no values are present for that columns ..

    Hi all, This looks like a wierd requirement ..In my ALV report, i am displaying around 30 fields. Among those , based on the input ,data will not be there for some  of the columns .. In the output we want to hide those columns eg: Matnr     Descr