To remove  duplicate  data using connect by prior

Hi ,
I want to details of the employee whom reporting to without duplication .
In table data,one employee reporting to two employees.so that reporting to process is coming two times.
Query:
SELECT lpad(' ', (level - 1) * 2) || EMPLOYEE_NAME as EMP_NAME,SUP_BU AS BU_CODE,SUP_REP_BU,EMP_NO,EMPLOYEE_NAME,LEVEL AS THE_LEVEL
FROM ATTD_REPORT_TO_VW
WHERE EMP_NO IS NOT NULL
CONNECT BY PRIOR SUP_BU = SUP_REP_BU
START WITH SUP_BU = :p_bu
BUT i get the duplicate data,SUPPOSE i remove the duplication using distinct keyword ,the order of hierarchical is going wrong.
Pls provide the solution.
Thanks ,
Maran

plz ask this question in seperate SQL/PLSQL forum and also provide more information with sample data

Similar Messages

  • OWB - possible to use connect by prior in mappings

    Hi,
    We get data supplied in hierarchical table and like to populate column on downstream table with level in hierarchy (parent, child or grandchild).
    In sql can use connect by prior.
    Is it possible to use this in mapping?
    Thanks

    Check this:
    https://blogs.oracle.com/warehousebuilder/entry/connect_by_in_owb_10gr2_hierar

  • Remove duplicates without using Sort OR Script compnent OR Staging ?

    Team , Can some advise on how do we go about removing duplicates without using  either of above option quoted in the subject lines ? My source is a huge  flat file  .
    Thanks in advance !
    Rajkumar Yelugu

    I think you can do like this
    1. Add a Data Flow Task with flat file source
    2. Add a multicast to flat file source
    3. Join an output from Multicast to Aggregate transform and group by your required field and take min or max over a unique valued column(s) (id or date or primary key)
    4. Add a Merge join transform and  add the multicast output and Aggregate Transform outputs as sources. join on the group by fields from aggregate and include min/max column also in output
    5. Add a conditional split and define an output as unique valued column(s) >(<) Min/Max value from aggregate
    6. Join the defined output to your destination to get only distinct records from the duplicate sets
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • Query tuning for query using connect by prior

    I have written following query to fetch the data. The query is written in this format because there are multiple rows, which make one recrd and we need to bring that record into one row.
    For one CAT(commented here), this query takes around 4 minutes and fetches 6900 records but when it runs for 3 CAT, it takes 17 mins.
    I want to tune this as this has to run for 350 CAT values.
    It is doing FTS on the main table. I tried to use different hints like PARALLEL, APPEND (in insert) but nothing worked.
    The cost of the query is 51.
    Any help/suggestions will be appreciated.
    SELECT DISTINCT MIN(SEQ) SEQ,
    PT, APP, IT, LR, QT,CD, M_A_FLAG,
    STRAGG(REM) REM, -- aggregates the data from different columns to one which is parent
    CAT
    FROM (WITH R AS (SELECT CAT, SEQ, PT, M_A_FLAG, IT, LR,QT,CD, REM, APP
    FROM table1
    WHERE REC = '36' AND M_A_FLAG = '1'
    --AND CAT = '11113')
    SELECT CAT, SEQ,
    CONNECT_BY_ROOT PT AS PT,
    CONNECT_BY_ROOT APP AS APPL,
    M_A_FLAG,
    CONNECT_BY_ROOT IT AS IT,
    CONNECT_BY_ROOT LR AS LR,
    CONNECT_BY_ROOT QT AS QT,
    CONNECT_BY_ROOT CD AS CD,
    REM
    FROM R A
    START WITH PT IS NOT NULL
    CONNECT BY PRIOR SEQ + 1 = SEQ
    AND PRIOR CAT = CAT
    AND PT IS NULL)
    GROUP BY PT, APP, IT,LR, QT, CD, M_A_FLAG, CAT
    ORDER BY SEQ;
    Thanks.
    Edited by: user2544469 on Feb 11, 2011 1:12 AM

    The following threads detail the approach and information required.
    Please gather relevant info and post back.
    How to post a SQL tuning request - HOW TO: Post a SQL statement tuning request - template posting
    When your query takes too long - When your query takes too long ...

  • Hierarchical query with out using Connect by prior

    Hi Guys,
    I am supporting a product which is enterprise based and only allowd to write queries which are ANSII standard.
    I have an requirement like If I provide the child I need to know all the parents till  highest level.
    My table structure is like below
    Table_name :  Org_unit
    Columns are
    Org_unit_id name desc  parent_org_unit_id
    I wil pass the org_unit id and want to list all the parents of the chile org_unit_id and it has to be accomplished without  using connec by prior.
    Please suggest me some ideas and aprroches
    I am using Orcle 11g version

    Hi,
    960593 wrote:
    Hi Guys,
    I am supporting a product which is enterprise based and only allowd to write queries which are ANSII standard.
    I have an requirement like If I provide the child I need to know all the parents till  highest level.
    My table structure is like below
    Table_name :  Org_unit
    Columns are
    Org_unit_id name desc  parent_org_unit_id
    I wil pass the org_unit id and want to list all the parents of the chile org_unit_id and it has to be accomplished without  using connec by prior.
    Please suggest me some ideas and aprroches
    I am using Orcle 11g version
    The data model you posted (org_unit_id as primary key, parent_org_unit_id as foreign key to the same table for the parent, when there is a parent) is called the Adjacency Model because it keeps track of which nodes are adjacent (or next to) each other.
    I'm familiar with 2 other ways to model hierarchies: the Nested Sets Model, and what I call the Lineage Model.  I'll show how to find a given node's ancestors (in hierarchical order) in each model.  Neither the Nested Sets nor the Lineage Model requires CONNECT BY or recursive WITH clauses to work.
    The following table contains all the columns necessary for using each of these 3 models:
         EMPNO        MGR ENAME      LINEAGE                    NS_LOW NS_HIGH
          7839            KING       /7839/                          1      28
          7698       7839 BLAKE      /7839/7698/                     2      13
          7499       7698 ALLEN      /7839/7698/7499/                3       4
          7900       7698 JAMES      /7839/7698/7900/                5       6
          7654       7698 MARTIN     /7839/7698/7654/                7       8
          7844       7698 TURNER     /7839/7698/7844/                9      10
          7521       7698 WARD       /7839/7698/7521/               11      12
          7782       7839 CLARK      /7839/7782/                    14      17
          7934       7782 MILLER     /7839/7782/7934/               15      16
          7566       7839 JONES      /7839/7566/                    18      27
          7902       7566 FORD       /7839/7566/7902/               19      22
          7369       7902 SMITH      /7839/7566/7902/7369/          20      21
          7788       7566 SCOTT      /7839/7566/7788/               23      26
          7876       7788 ADAMS      /7839/7566/7788/7876/          24      25
    The Lineage Model keeps track of all of a given nodes ancestors, so if all you need to find are the primary keys of a given node, it's really trivial: it's all in the lineage column.  If you want to find more information about those ancestors, then you can do a self-join, like this:
    SELECT    a.empno, a.ename, a.lineage
    FROM      emp  a
    JOIN      emp  d   ON  d.lineage  LIKE '%/' || a.empno || '/%'
    WHERE     d.ename  IN ('ADAMS')
    ORDER BY  d.ename
    ,         a.lineage
    Output:
         EMPNO ENAME      LINEAGE
          7839 KING       /7839/
          7566 JONES      /7839/7566/
          7788 SCOTT      /7839/7566/7788/
          7876 ADAMS      /7839/7566/7788/7876/
    The Nested Sets model is harder to understand.
    Imagine everyone in the hierarchy standing on a wide staircase, as if for a group picture; everyone on the same level standing on the same step.  Everyone is holding up an umbrella that is wide enough to cover himself and all the people who are under him in the hierarchy.  The people with no underlings have small umbrellas, denoted like this "<-SMITH->", and peole that manage others have bigger umbrellas, like this: <-------- JONES -------->.  So the group picture might look like this:
    <-------------------------------------------- KING --------------------------------------------->
      <---------------------- BLAKE --------------------->  <-- CLARK -->  <-------- JONES -------->
       <-ALLEN-> <-JAMES-> <-MARTIN-> <-TURNER-> <-WARD->    <-MILLER->     <-- FORD--> <--SCOTT-->
                                                                             <-SMITH->   <-ADAMS->
    Each parent's umbrella covers all of his descendants (children, grandchildren, etc.), and nobody else.
    Now draw vertical lines trom the edges of each umbrella downwards, and number those lines from left to right:
    <-------------------------------------------- KING ------------------------------------------------>
    |                                                                                                  |
    | <---------------------- BLAKE --------------------->  <-- CLARK ->   <-------- JONES ----------> |
    | |                                                  |  |          |   |                         | |
    | |<-ALLEN-> <-JAMES-> <-MARTIN-> <-TURNER-> <-WARD->|  |<-MILLER->|   |<-- FORD--> <--SCOTT---> | |
    | ||       | |       | |        | |        | |      ||  ||        ||   ||         | |          | | |
    | ||       | |       | |        | |        | |      ||  ||        ||   ||<-SMITH->| |<-ADAMS-> | | |
    | ||       | |       | |        | |        | |      ||  ||        ||   |||       || ||       | | | |
                                               1 1      11  11        11   112       22 22       2 2 2 2
    1 23       4 5       6 7        8 9        0 1      23  45        67   890       12 34       5 6 7 8
    The numbers corresponding to the left arnd right edges of each umbrella are what I called ns_low and ns_high in the table.  Each employyes ns_low and ns_high numbers will be inside the range of each of his ancestors ns_low and ns_high.
    To find the ancestors of a given node in the nested set model you can do this:
    SELECT   a.empno, a.ename, a.ns_low, a.ns_high
    FROM   emp  a
    JOIN      emp  d  ON  d.ns_low  BETWEEN  a.ns_low
                                    AND      a.ns_high
    WHERE     d.ename  IN ('ADAMS')
    ORDER BY  d.ename
    ,         a.ns_low
    Both the Lineage and Nested Sets models are good for tree structures only, whereas the Adjacency Model can handle other kinds of graphs, including graphs with loops.
    Both the Lineage and Nested Sets models can be very difficult to maintain if the hierarchy is re-organized.
    I'd like to repeat some of the warnings that others have made.  You could write separate code for each system (Oracle, SQL Server, ...) that you want to run in, and the code for each system will be more or less different.  You're looking for some code that will get the same results in all systems.  That code will be more complicated that the most complicated of the single-system versions, and it will be sloweer than the slwoest of the single-system versions.  You're giving up a lot of functionality, and probably also ease of maintenance, by writing code that has to work on multiple systems without changes.
    Here's how I created the emp table shown above from scott.emp:
    CREATE TABLE    emp
    AS
    WITH    connect_by_results  AS
        SELECT  empno, mgr, ename
        ,       LEVEL   AS lvl
        ,       ROWNUM  AS r_num
        ,       SYS_CONNECT_BY_PATH (empno, '/') || '/'   AS lineage
        FROM scott.emp
        START WITH mgr IS NULL
        CONNECT BY mgr = PRIOR empno
        ORDER SIBLINGS BY ename
    SELECT empno, mgr, ename, lineage
    ,       (2 * r_num) - lvl            AS ns_low
    ,       (2 * r_num) + ( 2 * (
                                    SELECT  COUNT (*)
                                    FROM    connect_by_results
                                    WHERE   lineage  LIKE '%/' || cbr.empno || '/%'
                        - (lvl + 1)      AS ns_high
    FROM connect_by_results   cbr
    This relies on the fact that the hierarchy in scott.emp has only one root (that is, a node with no parent).  Computing the Nested Sets numbers is a little more complicated if you can have multiple roots.

  • Problem Creating a query for a hierarchical tree. [using connect by prior]

    Hi all,
    I have 2 tables.
    box (box_id, box_name)
    item(item_id, item_name, box_id)
    In a box there are several items.
    I want to create a hierachical tree to display items that are present in each box.
    LIKE:
    |---BOX1
    | |----ITEM 1
    | |----ITEM 2
    |
    |---BOX2
    | |----ITEM 1
    | |----ITEM 2
    Currently i am trying this query:
    SELECT -1 state, box_name, 'icon' icon, box_id val
    from box b, item i;
    I don't know what value to put for level, i don't know how to code the 'connect by prior' part.
    Could you please advise me?
    Michaël.
    PS. Then i will eventually use this query in forms builder.

    Note the name of this forum is "SQL Developer *(Not for general SQL/PLSQL questions)*" - so only for issues with the SQL Developer tool. Please post these questions under the dedicated SQL And PL/SQL forum.
    Regards,
    K.

  • How to remove Exif data using terminal

    I want to remove Exif data from images using Terminal
    I've googled and cant find anything
    There's a Linux command, but nothing fro Terminal - or at least I cant find
    Thanks
    Omar

    @Frank Caggiano, thanks. i only want to remove and not do anything else. exiftool allows u to write as well
    my ideal solution: not to install anything
    that's something that comes from windows: fearing that installing things will clog up ur system. lol
    i need imagemagik for other image editing anyway
    thanks for the replies

  • How to get the root node for a child using connect by prior

    Hi,
    I searched at many places to do this but not able to get the exact o/p sp posting my question here.
    I have a table with parent_id and child_id columns. The levels of this parent_child can be many but my aim is to find the ultimate parent ( dont know the right term)
    like if I have a child_node= xyz and its parent= pqr and its parents=lmn which might be ultimate parent which doesnt have any further parent.
    So if i start with child_code= "xyz" then i should get the parent as "lmn" and not the immediate parent "pqr".
    Please help.
    Thanks,
    Aashish

    To find the Parent on emp table:
    select empno,ename,level
    from emp
    where level=3
    start with empno=7934
    connect by  empno= prior mgrTo find the Child on emp table:
    select empno,ename,level
    from emp
    where level=1
    start with empno=7934
    connect by prior empno=  mgrBut you need to know the level or position to specify the level of parent or child. But there are some other possible options available if we can know the requirement properly.
    Edited by: Vasista on Jan 11, 2011 2:27 AM
    Edited by: Vasista on Jan 11, 2011 2:30 AM

  • Removing Duplicate Data via cursor

    Hello friends just wondering if anyone might be able to lead me down the right path to get this script written. I have a table with millions of duplicate rows, but with luck I have a column that has UUIDs that are used for another database to look at. So I have a column to which I can base my query off of. Basically I want to run a cursor to grab one instance of the duplicate rows and delete the rest. I was thinking that I could use the max rowid and put that in a varaiable and use that to grab one UUID to not delete. Anyway just wanted to bounce this off a few people who are much better at this kind of thing than myself.
    Thanks in advance for any help insight you might be able to provide.
    Luke

    Hey Justin thank you for the reply, no i'll be honest and just say we got lucky that they had put a function on this table by mistake that populated a UUID column that they "thought" they were going to need. As long as one of the dupes remains that's all that is needed. The table over 70million rows as it sits right now. I want to do some data cleanup before I do any kind of tweaking to it as far as partitioning and what not.
    What happens is there isn't any primary keys or constraints on these tables at all... And there are 3rd party programs that users can insert any data they want. So what they do is run a report they already ran by accident and just insert that info in the table again... well as soon as I can get this cleaned up I'm going to be adding a constraint so this can't happen any more.
    Almost forgot... like I said there are millions of dupes, but it's not just one row that is duplicated. Here is an example of it:
    Table: dups_are_cool
    ID, date, name, UUID
    123, FEB03, Luke, unique UUID
    123, FEB03, Luke, unique UUID
    123, FEB03, Luke, unique UUID
    321, DEC99, John, unique UUID
    321, DEC99, John, unique UUID
    321, DEC99, John, unique UUID
    321, DEC99, John, unique UUID
    321, DEC99, John, unique UUID
    999, MAY81, Don, unique UUID
    999, MAY81, Don, unique UUID
    So what I want to do is take one of the UUIDs and then delete the rest of the rows that are duplicate. Since there are millions of rows with a different number of occurrences doing it one occurrence at a time might take me a bit too long hehe
    Message was edited by:
    Luke22
    Message was edited by:
    Luke22

  • Want to remove Duplicate data...

    Hi,
    I have three diff queries which product a similar output.
    1) SQL Statement return
    Product Amount1
    A 100
    B 100
    C 100
    2) SQL Statement return
    Product Amount2
    D 200
    B 200
    E 200
    3) SQL Statement return
    Product Amount3
    A 300
    F 300
    D 300
    Now i want out in the following manner:
    Product Amount1 Amount2 Amount3
    A 100 300
    B 100 200
    C 100
    D 200 300
    E 200
    F 300
    G
    I cannot join these table (SQL) as 1 might not have matching records in 2 & 3 respectively.
    Kindly help
    Regards,
    RSD

    Hi,
    I cannot join these table (SQL) as 1 might not have matching records in 2 & 3 respectively.Although the simpler solution have been provided in above post. Just thought to show you an example by using JOIINS.
    SQL> ed
    Wrote file afiedt.buf
      1  WITH T1 as (SELECT 'A' prd, 100 amt FROM DUAL UNION ALL SELECT 'B', 100 FROM DUAL UNION ALL SELECT 'C', 100 FROM DUAL),
      2  T2 as (SELECT 'D' prd, 200 amt FROM DUAL UNION ALL SELECT 'B', 200 FROM DUAL UNION ALL SELECT 'E', 200 FROM DUAL),
      3  T3 as (SELECT 'A' prd, 300 amt FROM DUAL UNION ALL SELECT 'F', 300 FROM DUAL UNION ALL SELECT 'D', 200 FROM DUAL)
      4  SELECT prd,sum(amt1),sum(amt2),sum(amt3) FROM (
      5  SELECT NVL(NVL(t1.prd,t2.prd),t3.prd) prd,t1.amt amt1,t2.amt amt2,t3.amt amt3
      6  FROM T1
      7  FULL OUTER JOIN t2 on (t1.prd = t2.prd)
      8  FULL OUTER JOIN t3 on (t2.prd = t3.prd and t1.prd=t3.prd)
      9  ) GROUP BY prd
    10*  ORDER bY prd
    SQL> /
    P  SUM(AMT1)  SUM(AMT2)  SUM(AMT3)
    A        100                   300
    B        100        200
    C        100
    D                   200        200
    E                   200
    F                              300
    6 rows selected.
    SQL>Cheers,
    Avinash

  • Can you remove Meta Data using Acrobat 7

    Mac OSX
    Acrobat 7.0
    Hello,
    Is this possible. If not is it available in another version?
    Thanks

    I think I found out how to do this. I would appreciate if someone could confirm the accuracy of this.
    File > Document Properties > Descriptionl > Additional Metadata > Advanced
    Select the data and click Delete, click OK.

  • How to avoid duplicate data while inserting from sample.dat file to table

    Hi Guys,
    We have issue with duplicate data in flat file while loading data from sample.dat file to table. How to avoid duplicate data in control file.
    Can any one help me on this.
    Thanks in advance!
    Regards,
    LKR

    No, a control file will not remove duplicate data.
    You would be better to use an external table and then remove duplicate data using SQL as you query the data to insert it to your destination table.

  • How to use simple SQL instead of Connect By Prior

    Currently, I am using "connect by prior" query in the application, but for reason I don�t want to use this connect by query so can any one please tell how does I get the same result by using SQL, I tried this by using procedure but unable to get the same result, specially LEVEL of the tree.
    So please tell, how would I get the correct data.
    Thanks in advance,
    AMIT.

    Hi,
    Whenever you have a question, it helps to post:
    (1) The version of Oracle (and any other relevant software) you're using
    (2) A little sample data (just enough to show what the problem is) from all the relevant tables
    (3) The results you want from that data
    (4) Your best attempt so far (formatted) I don't believe the unformated code you posted is what you're really running, since it has a syntax error ("... WHERE START WITH ..."). Please post code that really works with the sample data you posrted.
    (5) The full error message (if any), including line number
    Executable SQL statements (like "CREATE TABLE AS ..." or "INSERT ..." statements) are best for (2).
    If you can present your problem using commonly available tables (for example, scott.emp, which contains a hierarchy), then you can omit (2).
    Formatted tabular output is okay for (3). Type these 6 characters
    &#123;code&#125;
    (small letters only, inside curly brackets) before and after the tabular text, to preserve spacing.
    As Alex said, why don't you want to use CONNECT BY?
    Are you getting the correct results now, but just looking for a different way of getting them?
    Depending on your exact requirements, you could write a PLSQL function that mimics LEVEL. Don't expect it to be fast.
    Nested Sets is a completely different way of modeling trees.
    Some things are much easier with Nested Sets than they are using the Adjacency Model (the parent-child model that uses CONNECT BY).
    But some things are much harder with Nested Sets, and LEVEL is one of them.

  • MODEL clause using CONNECY BY PRIOR

    Hello.
    I have the following table, CONTEXT_MAPPING:
    Name Null? Type
    ID NOT NULL NUMBER(38)
    CONTEXT_ITEM NOT NULL VARCHAR2(30)
    ID_1 NUMBER(38)
    ID_2 NUMBER(38)
    ID_3 NUMBER(38)
    ID_4 NUMBER(38)
    ID_5 NUMBER(38)
    It's a self referencing table, i.e. ID_1 will refer to an ID from another row in CONTEXT_MAPPING, and the same for ID_2/3/4/5.
    Easily illustrated through the following hierarchical data:
    ID CONTEXT_ITEM ID1 ID2 ID3 ID4 ID5
    1 P_DMA_NDA_ID
    2 P_DS_NDA_ID 1
    3 P_AST_NDA_ID 2 1
    4 P_AGI_ID 3
    5 P_ASG_NDA_ID 3
    6 P_NTS_FACTS 5 5
    7 P_IDE_VALUE 2 1
    8 P_EIT_VALUE 2 1
    9 P_TRI_TABLE 4 6 7 8
    10 P_TRI 9
    11 P_PRICE1 6 10 6
    12 P_PRICE2 6 10 6
    What I want to do, is for any context item, to identify ALL of its dependencies throughout the tree.
    For example:
    P_PRICE2 has a link to P_NTS_FACTS (ID1 & ID3 = 6) and P_TRI (ID2 = 10)
    P_NTS_FACTS has a link to P_ASG_NDA_ID (ID1 & ID2 = 5), which in turn links to P_AST_NDA_ID (ID1 = 3)...
    P_TRI has a link to P_TRI_TABLE (ID1 = 9), which in turn links to multiple context items (ID1 = 4, ID2 = 6 etc.) ....
    ....and so on, until we get to the "root" record, P_DMA_NDA_ID.
    So, to see the complete dependency tree for P_PRICE2, I would expect to see a hierarchical result-set like this:
    ID CONTEXT_ITEM ID1 ID2 ID3 ID4 ID5
    12 P_PRICE2 6 10 6
    10 P_TRI 9
    9 P_TRI_TABLE 4 6 7 8
    4 P_AGI_ID 3
    6 P_NTS_FACTS 5 5
    5 P_ASG_NDA_ID 3
    3 P_AST_NDA_ID 2 1
    7 P_IDE_VALUE 2 1
    8 P_EIT_VALUE 2 1
    2 P_DS_NDA_ID 1
    1 P_DMA_NDA_ID
    Ideally I want to do this in a single SQL statement - I've tried using CONNECT BY PRIOR in conjunction with LEVEL to do this, but it only performs a hierarchical join for a single child-parent relationship, and I need this to work for up to five children.
    Was starting to wonder if I could use the MODEL clause in conjunction with CONNECT BY PRIOR to achieve this - does anyone have any idea whether this type of recursion is possible?
    Thanks,
    Ray

    it only performs a hierarchical join for a single child-parent relationshipBeg to differ.
    Oracle Database 10g Release 10.2.0.2.0 - Production
    SQL> CREATE TABLE context_mapping (
      2     id NUMBER(38),
      3     context_item VARCHAR2(30),
      4     id_1 NUMBER(38),
      5     id_2 NUMBER(38),
      6     id_3 NUMBER(38),
      7     id_4 NUMBER(38),
      8     id_5 NUMBER(38));
    Table created.
    SQL> INSERT INTO context_mapping VALUES (1, 'P_DMA_NDA_ID', NULL, NULL, NULL, NULL, NULL);
    1 row created.
    SQL> INSERT INTO context_mapping VALUES (2, 'P_DS_NDA_ID', 1, NULL, NULL, NULL, NULL);
    1 row created.
    SQL> INSERT INTO context_mapping VALUES (3, 'P_AST_NDA_ID', 2, 1, NULL, NULL, NULL);
    1 row created.
    SQL> INSERT INTO context_mapping VALUES (4, 'P_AGI_ID', 3, NULL, NULL, NULL, NULL);
    1 row created.
    SQL> INSERT INTO context_mapping VALUES (5, 'P_ASG_NDA_ID', 3, NULL, NULL, NULL, NULL);
    1 row created.
    SQL> INSERT INTO context_mapping VALUES (6, 'P_NTS_FACTS', 5, 5, NULL, NULL, NULL);
    1 row created.
    SQL> INSERT INTO context_mapping VALUES (7, 'P_IDE_VALUE', 2, 1, NULL, NULL, NULL);
    1 row created.
    SQL> INSERT INTO context_mapping VALUES (8, 'P_EIT_VALUE', 2, 1, NULL, NULL, NULL);
    1 row created.
    SQL> INSERT INTO context_mapping VALUES (9, 'P_TRI_TABLE', 4, 6, 7, 8, NULL);
    1 row created.
    SQL> INSERT INTO context_mapping VALUES (10, 'P_TRI', 9, NULL, NULL, NULL, NULL);
    1 row created.
    SQL> INSERT INTO context_mapping VALUES (11, 'P_PRICE1', 6, 10, 6, NULL, NULL);
    1 row created.
    SQL> INSERT INTO context_mapping VALUES (12, 'P_PRICE2', 6, 10, 6, NULL, NULL);
    1 row created.
    SQL> SELECT DISTINCT id, context_item, id_1, id_2, id_3, id_4, id_5
      2  FROM   context_mapping
      3  START WITH id = 12
      4  CONNECT BY id IN (PRIOR id_1, PRIOR id_2, PRIOR id_3, PRIOR id_4, PRIOR id_5)
      5  ORDER BY id DESC;
            ID CONTEXT_ITEM                         ID_1       ID_2       ID_3       ID_4       ID_5
            12 P_PRICE2                                6         10          6
            10 P_TRI                                   9
             9 P_TRI_TABLE                             4          6          7          8
             8 P_EIT_VALUE                             2          1
             7 P_IDE_VALUE                             2          1
             6 P_NTS_FACTS                             5          5
             5 P_ASG_NDA_ID                            3
             4 P_AGI_ID                                3
             3 P_AST_NDA_ID                            2          1
             2 P_DS_NDA_ID                             1
             1 P_DMA_NDA_ID
    11 rows selected.
    SQL>

  • Referencing multiple cells and removing duplicate values.

    Hello.
    I have a very complicated question, to be honest I am not totally sure if numbers is capable of handling all of this but it's worth a shot.
    I am working on a spreadsheet for organising a film. I've had the templates for years but I'm now using numbers to automate it as much as possible. Everything was going well until I hit the schedule/callsheet.
    On other sheets I can tell it to "look up scene two" it will then look up the correct row and find everything I need. On the callsheet however I might say "we're filming scenes two, five and nine" and numbers gets confused with the multiple values, Is there anyway around this?
    Also, if there is, I have a more complex question to ask. Is it possible for numbers to find and remove duplicate data? For example lets say scene two and five require Alice, but scene nine requires bob. If numbers just adds that info together it will display the result "Alice Alice Bob", is there a way to get it to parse the text, recognise the duplicate value and remove the unnecessary Alice? 
    I realise that numbers has limitations so it may not be able to do everything I want, however every bit I can automate saves me hours so even if I can only get half way there, totally worth it.
    Thanks in advance for any help you can offer, all the best.

    Ah excellent thank you.
    I've modified it to there are now multiple (well only four for now until I get this in better shape) indexes for finding a scene. And assigning each block to a new row.
    I only have one slight reservation about this. If I create 10 rows, it totally works, most of the time we'll only shoot three scenes a day so it's just blank space... However Murphy's law will inevitable raise its ugly head and put me in a situation where we are shooting 11 scenes in a day. 
    For countif, I think I get what you mean... Kinda. Basicially I would create a cell which combines the character strings from each scene into one long scene. Then I would have 100 extra cells (Lets say 100 so I'll never run out) each linked to the cast list, using the character name as a variable. These cells will each parse through the string to find their character name. If it appears then a true value comes up. This will remove duplicates as each cell will only respond once. So if Alice appears in every scene shooting that day, the cell will still only light up once. Is that it.
    One other question. Whenever I combine filled cells with blank cells. I usually gets the data from the filled cells, with a 0 for each blank cell. Usually this isn't a problem, but if I want to keep this flexible then I'll have quite a few blanks. The actor example above could result in 98 zeroes. Is there anyway to have blanks just not show up at all.
    I'll email the spreadsheet in a moment, a lot of it is still rough and under construction, but you should be able to see where it's all going hopefully.
    Thanks again, you have been extraordinarily helpful. 

Maybe you are looking for

  • Upgrading MacBook Pro 13" (mid-2010) HDD with Bootcamp Partition

    I'm upgrading my macbook pro's hdd from 250 gb to 1tb. My OS is lion 10.7.5 and i also have windows 7 installed on my bootcamp partition. The following are the details to the HDD i plan to buy. Samsung Spinpoint M8 1 TB Laptop Internal Hard Drive (ST

  • Can I change the name of a VLAN in the WLAN controller?

    We have three WLAN controllers and I recently noticed that a VLAN interface is not properly named.  It doesn't match the other controllers, and won't work right when using enterprise templates in WCS, etc. I would like to rename that interface so tha

  • Randomly logged out

    Lately I have experienced being logged out at random intervals on my laptop. That is, after some time (of activity or inactivity) I get logged out and Slim is executed. This is the normal behaviour when killing X manually with ctrl-alt-backspace, so

  • Fm 10: Show Element Descriptive Tags

    Fm 10 > Element Catalog Display Options: what is the option "Show Element Descriptive Tags" supposed to do? It's not explained in the Fm 10 Help (or I am unable to find it, but that applies to almost anything I search for in this "Help"). Thanks Yves

  • Duplicate Photo Detection

    I just updated my iMac to Snow Leopard and also installed iLife '09. I noticed when downloaded some photos from my camera just now that the program does not give me the option anymore to NOT download duplicate photos. Becasue of that I have a bunch o