Plz help me in this query for the tree

hi All
I want to bulid tree that start with for example
schema name "scott"
then table "dept,emp
then ename in table emp
root scott
parent dept
child emp_name
please help me in the query ?

user222 wrote:
any help my dearsIf you can draw one simple tree example. Then it will be easy to create query. Because i am confuse about the output. Just draw one example of your desired output tree. Then it will help to find solution.
And while writing query or any example so use the 6 digit before and after your query or example to keep the formatting in orignal format. Otherwise it becomes hard to read.
For more information see FAQ on right corner for page.
-Ammad                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

Similar Messages

  • Please help to modifiy this query for better performance

    Please help to rewrite this query for better performance. This is taking long time to execute.
    Table t_t_bil_bil_cycle_change contains 1200000 rows and table t_acctnumberTab countains  200000 rows.
    I have created index on ACCOUNT_ID
    Query is shown below
    update rbabu.t_t_bil_bil_cycle_change a
       set account_number =
           ( select distinct b.account_number
             from rbabu.t_acctnumberTab b
             where a.account_id = b.account_id
    Table structure  is shown below
    SQL> DESC t_acctnumberTab;
    Name           Type         Nullable Default Comments
    ACCOUNT_ID     NUMBER(10)                            
    ACCOUNT_NUMBER VARCHAR2(24)
    SQL> DESC t_t_bil_bil_cycle_change;
    Name                    Type         Nullable Default Comments
    ACCOUNT_ID              NUMBER(10)                            
    ACCOUNT_NUMBER          VARCHAR2(24) Y    

    Ishan's solution is good. I would avoid updating rows which already have the right value - it's a waste of time.
    You should have a UNIQUE or PRIMARY KEY constraint on t_acctnumberTab.account_id
    merge rbabu.t_t_bil_bil_cycle_change a
    using
          ( select distinct account_number, account_id
      from  rbabu.t_acctnumberTab
          ) t
    on    ( a.account_id = b.account_id
           and decode(a.account_number, b.account_number, 0, 1) = 1
    when matched then
      update set a.account_number = b.account_number

  • How to tune this query for the improve performance ?

    Hi All,
    How to tune this query for the improve performance ?
    select a.claim_number,a.pay_cd,a.claim_occurrence_number,
    case
    when sum(case
    when a.payment_status_cd ='0'
    then a.payment_est_amt
    else 0
    end
    )=0
    then 0
    else (sum(case
    when a.payment_status_cd='0'and a.payment_est_amt > 0
    then a.payment_est_amt
    else 0
    end)
    - sum(case
    when a.payment_status_cd<>'0'
    then a.payment_amt
    else 0
    end))
    end as estimate
    from ins_claim_payment a
    where a.as_of_date between '31-jan-03' and '30-aug-06'
    and ( a.data_source = '25' or (a.data_source between '27' and '29'))
    and substr(a.pay_cd,1,1) IN ('2','3','4','8','9')
    group by a.claim_number, a.pay_cd, a.claim_occurrence_number
    Thank you,
    Mcka

    Mcka
    As well as EXPLAIN PLAN, let us know what proportion of rows are visited by this query. It may be that it is not using a full table scan when it should (or vice versa).
    And of course we'd need to know what indexes are available, and how selective they are for the predicated you have in this query ...
    Regards Nigel

  • Plz help me design this query

    Hi,
    Can you’ll please help me with this query.
    Here is a little bit of background:
    One title can have multiple items associated with it.
    Table: TITLE has the master list of titles. TITLE_ID is the primary key.
    Table: ITEM has the master list of all items. ITEM_ID is the primary. This table also has the TITLE_ID which stores title for this item.
    Table: ITEM_STATUS has fields ITEM_ID and STATUS_ID. This field contains statuses for items. But not all items contained in the table ITEM are in this table.
    I want to find TITLE_ID’s whose all items (all ITEM_ID in table ITEM having same value for TITLE_ID) have a particular status (for example STATUS_ID = 2) in table ITEM_STATUS.
    Let’s say TITLE_ID = 1 has 5 items in table ITEM_ID and only 4 items out of it in table ITEM_STATUS with STATUS_ID = 2, then this TITLE_ID should not come. OR
    Let’s say TITLE_ID = 1 has 5 items in table ITEM_ID and all these 5 items are in table ITEM_STATUS but only 1 has STATUS_ID = 2, then this TITLE_ID should also not come
    In the above case only if all 5 items are contained in table ITEM_STATUS have STATUS_ID = 2 then this TITLE_ID should be reported by the query.
    What should be the query like for this one, I am fairly new to SQL so plz guide me.
    Thank you,
    Raja

    I haven't tested the query below. Try it and let me know for any issues:
    SELECT     DISTINCT t.title_id
         FROM     title t,
                        item i,
                        item_status its
    WHERE     t.title_id = i.title_id
         AND     i.item_id = its.item_id
         AND     NOT EXISTS     (
                                                           SELECT 1
                                                                FROM item_status its1
                                                           WHERE its1.item_id = i.item_id
                                                                AND status_id <> 'YOUR_ITEM_STATUS'
                                                      )

  • Plz help in tuning this query......

    SELECT "LAN","VEF_REF_NO","VF_TYPE_CODE","APPLICANT_TYPE","MANDATORY","OPTIONAL","COMPLETE","DT_COMPLETED","REFIRENO","ROLE","USER_ID","DT_LASTUPDATED","TEMPLATEFIRED"
    FROM T_VER_STRATEGY_DETAILS M
    WHERE VF_TYPE_CODE =1 AND
    APPLICANT_TYPE ='A' AND
    DT_LASTUPDATED=
    (SELECT MAX(DT_LASTUPDATED)
    FROM T_VER_STRATEGY_DETAILS
    WHERE LAN = M.LAN AND
    VF_TYPE_CODE =1 AND APPLICANT_TYPE ='A')
    This seems to be a correlated query.
    i tried using combined index on
    (VF_TYPE_CODE ,APPLICANT_TYPE ,DT_LASTUPDATED)
    and another index on
    (LAN,VF_TYPE_CODE ,APPLICANT_TYPE ) but the plan or cost remains unchained.
    plz help

    [url http://forums.oracle.com/forums/thread.jspa?threadID=501834&tstart=0]When your query takes too long...

  • Plz help to make this query......very urgent

    I ve two tables <br>
    <br>
    First one is <b>grn_dtl</b> containing following fields     <br> <br> <br>
    <u><b>
    item_code        ent_dt       qty    doc_no </u></b><br>
    11001318        09/09/2003   5    56300501 <br>
    11001318        11/09/2004        9    56300502 <br>
    11001318        12/05/2005       2    56300503 <br>
    11001319        22/06/2004        0    56300504 <br>
    11001320        09/06/2005        0    56300505 <br>
    11001320        11/08/2004        8    56300506 <br>
    11001320        30/05/2005       4    56300507 <br>
    11001320        21/06/2003       1    56300508 <br>
    11001321        25/09/2004       1    56300509 <br>
    11001321        15/07/2004       1    56300510 <br>
    11001321        01/08/2004       2    56300511 <br>
    11001322        02/06/2004       1    56300512 <br>
    11001322        22/06/2004        2    56300513 <br>
    11001323        12/09/2004        1    56300514 <br>
    11001323        08/05/2004        4    56300515 <br>
    11001323        17/08/2004        5    56300516 <br>
    11001323        28/06/2004        2    56300517 <br>
    <br><br>
    second one is <b>item_mst</B> containing following fields     <br>
    <br>
    <u><b>          
    item_code         description         leadtim   kanbandate</u></b><br>
    11001318           aaaaaaaaaaa            15             22/04/2004<br>
    11001319           aaaaaaaaaaa           15             02/12/2004<br>
    11001320           aaaaaaaaaaa           15             14/07/2005<br>
    11001321           aaaaaaaaaaa           15              23/02/2004<br>
    11001322           aaaaaaaaaaa           15             05/10/2004<br>
    11001323           aaaaaaaaaaa           15             17/05/2004<br>
    11001324           aaaaaaaaaaa           15             27/12/2004<br>
    11001325           aaaaaaaaaaa           15             07/08/2004<br>
    <br><br><br><b>
    From the above two tables I want the combine SQL query which will display item_code its description ,kanbandate from item_mst table and will also display the minimum ent_dt of each corresponding item_code alongwith the qty and doc_no.the item_code should not be repeated .<br>
    I want to run the query from sql query analyzer</b><br><br>
    the result should be like this<br><br>
    <b></u>item_code  desc              ent_dt      qty    doc_no</b></u>
    <br>
    11001318       aaaaaaaaaaa        09/09/2003        5        56300501<br>
    11001319       aaaaaaaaaaa        22/06/2004       0        56300504<br>
    11001320       aaaaaaaaaaa        21/06/2003       1        56300508<br>
    11001321       aaaaaaaaaaa        15/07/2004        1       56300510<br>
    11001322       aaaaaaaaaaa        02/06/2004        1        56300513<br>
    11001323       aaaaaaaaaaa        08/05/2004        4       56300515<br>
    <br>
    <br>
    plz help me out ASAP
    null
    Message was edited by:
    aanchal_2008

    can you try this,
    SELECT DISTINCT im.item_code,
    im.descR,
    gd.ent_dt,
    gd.qty,
    gd.doc_no
    FROM item_mst im,
    grn_dtl gd
    WHERE im.item_code = gd.item_code (+)
    AND NOT EXISTS (
    SELECT 'later detail'
    FROM grn_dtl gd2
    WHERE gd2.item_code = gd.item_code
    AND gd2.ent_dt > gd.ent_dt)
    ITEM_CODE DESCR ENT_DT QTY DOC_NO
    11001318 aaaaaaaaaaa 2/12/2005 6 563005
    11001319 aaaaaaaaaaa 6/22/2004 0 563005
    11001320 aaaaaaaaaaa 6/9/2005 0 563005
    11001321 aaaaaaaaaaa 12/5/2005 5 563005
    11001322 aaaaaaaaaaa 6/22/2004 2 563005
    11001323 aaaaaaaaaaa 9/12/2004 1 563005
    11001324 aaaaaa
    11001325 aaaaaa
    8 rows selected

  • Plz help me with this query

    i need to get each manager name, his department name and for each year that is for 81,82,83,84 count of employee's under that manager from emp and dept tables .
    thanks in advance
    select distinct deptno, TO_CHAR (HIREDATE, 'YY'), count(*) from emp group by TO_CHAR(HIREDATE, 'YY'), DEPTNO ORDER BY TO_CHAR(HIREDATE, 'YY'), DEPTNO;
    the above query returns me count of employees ,year and deptno
    SELECT DISTINCT E2.ENAME , E1.ENAME, E1.DEPTNO, E1.MGR, E1.EMPNO, E1.SAL, D.DNAME, D.LOC FROM EMP E1, EMP E2, DEPT D WHERE E1.MGR = E2.EMPNO AND E1.DEPTNO = D.DEPTNO ORDER BY E1.DEPTNO;
    this query returned me manager names and employees under them
    Message was edited by:
    user450660

    At that point you're not too far off, you have most of what you need. In general, any time you see the use of DISTINCT it's a sign that either your query or your data model isn't designed quite right.
    SELECT m.ename,
           d.dname,
           TO_CHAR (e.hiredate, 'YY') AS hire_year,
           COUNT(*) AS emp_count
      FROM emp e, emp m, dept d
    WHERE e.mgr = m.empno
       AND m.deptno = d.deptno
    GROUP BY
           m.ename,
           d.dname,
           TO_CHAR (e.hiredate, 'YY');

  • Accent insensitive Search - plz help me correcting this query

    Hello,
    I just realized that with that query, if I search for "Montreal" (without the accent), I have all the following results, which is what I want
    SELECT
    "ID","TIT"
    from   "REGDOSSIERS" "RDO"
           where
             TRANSLATE(UPPER("TIT"),'ÀÂÉÈÊÎÔÛÙÜ','AAEEEIOUUU')
             like upper(nvl(replace('%' || "P1_REPORT_SEARCH || '%',' ','%'),"TIT"))
    RESULTS
    TIT
    Annuaires Lovell (Montréal et banlieue)
    Juridiction royale de Montréal. Dossiers, 1677-1769
    Montreal Witness, 1845-1938
    {code}
    But how to change it so when I look for: "Montréal" (with the accent) , I have also the same results? Right now, with Montréal, I have nothing
    thanks,
    Roseline
    Edited by: Roseline on 2009-10-01 18:58
    Edited by: Roseline on Oct 1, 2009 7:34 PM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    If you are on Oracle 10g you can use regexp expressions to do the search.
    Example
    with testdata as (select 'Montreal' txt from dual
                      union all select 'Montréal' txt from dual
                      union all select 'Montreâl' txt from dual
                      union all select 'Montreaux' txt from dual)
    /* end of test data creation */
    select txt from testdata
    where regexp_like (txt, 'Montr[[=e=]]al');
    txt
    Montreal
    Montréal[[=e=]] would be an equivalence class for the letter "e" and includes also searches for é, è, ê etc.
    The best solution mainly depends how your search string is build.
    If you just want to sort, then the nlssort function would be useful.
    Mentioning Nlssort I remembered there is a much better way to implement Accent insensitive search. You just need to set your NLS_SORT parameter correctly. Either to BINARY_AI (the AI means accent and case insensitiv) or add _AI to your nls langage.
    example
    ALTER SESSION SET NLS_COMP=LINGUISTIC;
    alter session set nls_sort = 'FRENCH';
    with testdata as (select 'Montreal' txt from dual
                      union all select 'Montréal' txt from dual
                      union all select 'Montreâl' txt from dual
                      union all select 'Montreaux' txt from dual)
    /* end of test data creation */
    select txt from testdata
    where txt = 'MONTREAL';
    no rows selects
    /* now change the nls sorting */
    alter session set nls_sort = 'FRENCH_AI';
    with testdata as (select 'Montreal' txt from dual
                      union all select 'Montréal' txt from dual
                      union all select 'Montreâl' txt from dual
                      union all select 'Montreaux' txt from dual)
    /* end of test data creation */
    select txt from testdata
    where txt = 'MONTREAL';
    txt
    Montreal
    Montréal
    MontreâlEdited by: Sven W. on Oct 2, 2009 8:34 AM
    Edited by: Sven W. on Oct 2, 2009 10:22 AM - corrected misleading regexp example.

  • Plz help me rectify this query

    Hi,
    I am trying to use a OR condition in NOT IN clause, is the SQL statement correct way:
    select name from master_list where ((id not in (select id from deleted_list)) OR (id not in (select id from inactive_list)))
    I there are two tables which contain ids which should be in not in clause.
    Thanks,
    Raja

    Hi,
    Whenever you post fomatted text on this site (and code should always be formatted), type these 6 characters:
    &#123;code&#125;
    (small letters only, inside curly brackets) before and after sections of formatted text, to preserve spacing.
    What is the problem?
    Are you getting an error message?
    Why not post the error message?
    Are you getting the wrong results?
    Post some sample data, and the results you want to get from that data.
    NOT IN will never be TRUE if the sub-query includes any NULL rows. I can't tell if that's possible with your tables or not..

  • Plz help to make this query......

    I ve two table <br>
    <br>
    First one is grn_dtl containing following fields     <br> <br> <br>
    <u><b>
    item_code        ent_dt       qty    doc_no </u></b><br>
    11001318        09/09/2003   5    56300501 <br>
    11001318        11/09/2004        9    56300502 <br>
    11001318        12/05/2005       2    56300503 <br>
    11001319        22/06/2004        0    56300504 <br>
    11001320        09/06/2005        0    56300505 <br>
    11001320        11/08/2004        8    56300506 <br>
    11001320        30/05/2005       4    56300507 <br>
    11001320        21/06/2003       1    56300508 <br>
    11001321        25/09/2004       1    56300509 <br>
    11001321        15/07/2004       1    56300510 <br>
    11001321        01/08/2004       2    56300511 <br>
    11001322        02/06/2004       1    56300512 <br>
    11001322        22/06/2004        2    56300513 <br>
    11001323        12/09/2004        1    56300514 <br>
    11001323        08/05/2004        4    56300515 <br>
    11001323        17/08/2004        5    56300516 <br>
    11001323        28/06/2004        2    56300517 <br>
    <br><br>
    second one is <b>item_mst</B> containing following fields     <br>
    <br>
    <u><b>          
    item_code         description         leadtime   kanbandate</u></b><br>
    11001318           AIR FILTERS            15             22/04/2004<br>
    11001319     AIR FILTER KIT DSK      15     02/12/2004
    11001320     AIR FILTER FOR 3.0     15     14/07/2005
    11001321     AIR FILTER NA 21323130      15     23/02/2004
    11001322     AMPERE METER DC-0-50     15     05/10/2004
    11001323     ACTUATER KIT     15     17/05/2004
    11001324     ACTUATOR HOSE      15     27/12/2004
    11001325     AIR GUN MEDIUM     15     07/08/2004
    from the above two tables I want the query which will display item_code its description ,kanbandate from item_mst table and will also display the minimum ent_dt of each corresponding

    select m.item_code,m.description,m.kanbandate,min(d.end_dt)
    from item_mst m,grn_dtl d
    where m.item_code = d.item_code
    group by m.item_code,m.description,m.kanbandate

  • Plz help me debug this query

    query
    create table third_party
    (customer_id varchar2,
    third_party varchar2,
    foreign key (third_party) references account(type),
    foreign key (customer_id) references customer(customer_id),
    primary key(customer_id,third_party));
    Error
    ORA-00906: missing left parenthesis

    Please see this ..these are done
    create table account
    (account_no number primary key,
    type varchar2(10),
    balance number(20) );
    create table registered_account
    ( account_no number primary key,
    customer_id varchar2(10),
    foreign key (account_no) references account(account_no),
    foreign key (customer_id) references registered_users(customer_id) );
    create table registered_users
    (customer_id varchar2(20) primary key,
    user_id varchar2(10),
    login_password varchar2(10),
    foreign key (customer_id) references customer(customer_id));
    create table transaction
    (transaction_id number primary key,
    to_account number,
    from_account number,
    tr_date date,
    amount number,
    customer_id varchar2(10),
    foreign key (to_account) references account(account_no),
    foreign key (from_account) references account(account_no),
    foreign key (customer_id) references customer(customer_id));
    create table has
    (customer_id,
    account_no,
    foreign key (customer_id) references customer(customer_id),
    foreign key (account_no) references account(account_no),
    primary key(customer_id,account_no));
    create table customer
    (customer_id varchar2(20)primary key,
    name varchar2(15),
    address varchar2(50),
    city varchar2(20),pin number(6),
    dob varchar2(10),ph_no number(10));
    The following is nt working
    create table third_party
    (customer_id varchar2(20),
    third_party varchar2(10),
    foreign key (third_party) references account(type),
    foreign key (customer_id) references customer(customer_id),
    primary key(customer_id,third_party));

  • Plz help in building this query .

    dear gurus i have problem i have two tables namely purchases
    product_id,invoice_no,invoice_date,purchase_rate,quantity
    and
    sales
    product_id,invoice_no,invoice_date,sales_rate,quantity
    i have to select sales.product_id,sales.quantity*sales.sales_rate and average of (purchase_rate*purchae.quantity) i.e average purchase price of particular product i.e. group by product_id and purchase price in between particular dates but i m unable to find any good soloution. any help plz
    null

    I'm not sure I understand your grouping goal, but...
    select sales.product_id,
    sales.quantity*sales.sales_rate sttl
    pur.avgp
    from sales
    (select avg ( purchase_rate *
    quantity) avgp,
    product_id
    from purchases
    group by product_id) pur
    where sales.product_id = pur.product_id
    and sales.invoice_date between
    '04-jun-1999' and '05-may-2001';
    If you need more complex grouping, you can add it.

  • Plz help me on this very simple error

    hello everybody...i'm very new to java programming...i'm unable to execute my program though it has been compiled...my coding is something like this and is very easy>>
    class abc
    public static void main(String [] args)
    System.out.println("hello");
    and at the time of execution...this error is shown up>>
    C:\Documents and Settings\Ishan\Desktop>java abc
    Exception in thread "main" java.lang.NoClassDefFoundError: abc
    Caused by: java.lang.ClassNotFoundException: abc
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClassInternal(Unknown Source)
    Could not find the main class: abc. Program will exit.
    plz help me on this. thanks.

    Follow the instructions in this tutorial:
    http://java.sun.com/docs/books/tutorial/getStarted/cupojava/index.html
    See problem solutions here:
    http://java.sun.com/docs/books/tutorial/getStarted/problems/index.html

  • Query on FBL3N................Urgent  plz help me on this.

    Hi Friends
         Here is my query,
    I am changing the tcode FBL3N to add one extra field into it and to display data in the name1 field for the spcific entries in the selection screen,
    After selecting the All item radio button and giving the range in the select-options when i am pressing F8 it is giving me the correct output,after that when i am trying to display the name1 field by selecting the ctrl+f8 button and pressing the apply button  it is giving me the error as
    "An internal error has arisen in the form routine ANALYZE_ACT_FIELDCAT
    for program RFITEM_INC.
    This is due to inconsistencies between table T021S (special fields) and
    structure RFPOSEXT."
    I changed everything to Y* but still it is giving the error.
    Plz help me in this if someone face the same prob or someone having idea on this.
    Thanks a lot in Advance
    Mrutyun^

    Hi Mrutyunjaya,
    Did you manage to resolve this error?
    Thanks and Regards
    Pras

  • When I run the same query for the second time it's faster, I want to reset this behavior

    I am running a query in oracle 11g select A from B where C = ':D' B has millions of records.
    The first time i run it it takes about 30 seconds, the second time i run the query it takes about 1 second.
    Obviously it's caching something and i want it to stop that, each time i run the query i want it to take 30s - just like it was running for the first time.
    The reason I want to reset this is because for testing purposes I want to measure this query at the very first time.
    Please help.
    Thanks & Best Regards,
    Dark

    user9359353 wrote:
    I am running a query in oracle 11g select A from B where C = ':D' B has millions of records.
    The first time i run it it takes about 30 seconds, the second time i run the query it takes about 1 second.
    Obviously it's caching something and i want it to stop that, each time i run the query i want it to take 30s - just like it was running for the first time.
    The reason I want to reset this is because for testing purposes I want to measure this query at the very first time.
    Please help.
    Thanks & Best Regards,
    Dark
    No - you do NOT want to do that. Not if you want to get results that really represent how that query will work in reality.
    See these two AskTom blogs where he discusses the reasons for NOT doing this in detail.
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:7413988573867
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:311990400346061304

Maybe you are looking for

  • "The operation could not be completed" Creating an iMovie

    Hello, Every time I go to create a Movie or project in iMovie it says, "The operation could not be completed" followed by "No other information is available about the problem." I have been recording several videos, and I need to edit them, get them o

  • How do I change the default paper size for printing?

    I am running Firefox 3.6.3. Recently, the default paper size for printing unexpectedly changed to a user-defined size of 3.00" x 4.57". It used to be letter size (8.5 x 11). The default paper size is 8.5 x 11 for everything else. I have tried changin

  • Downloads do not function., Downloads do not function., Downloads do not function.

    I have downloaded several programs and a video. Everything worked pretty well. Now nothing functions and I cannot download them again from App Store as the service is unavailable both from computer and from the phone. What to do?

  • Available space estimates different between iPhone and iTunes

    Hi, I've just noticed that looking at my iPhone is settings it says I have 708 MB available while in iTunes it says I have 1.66 GB available. They agree in the used amount. I've just synced it to see if that resolved it but it did not. Any ideas?

  • Add new columns to flatfile connection

    Hi, I have created a package and completed the development. Now, client is requesting to add few more columns to the target flatfile. I don't want to delete the connection and flat file destination components and re-create the both to reflect the new