Group multiply lines - HARD

Hello
NAME | FAMILY NAME |     x | There | BIRTH_DAY
KRIS | ONE | 324. 52. 2011 09-12
KRIS | SIX | 222. 111. 2011 09-13
KRIS | SSS | 1558. 13. 2011 09-13
ANNA | DDD | 7486 | 0     | 2011 09-12
TOM | DDD |     4853 | 111. 2011 09-12
JERRY | DDD | 6402 | 112. 2011 09-12
JACK | DDD | 957. 113. 2011 09-15
JACK | DDD | 11445.     368. 2011-09-19

I have the problem.
I need to aggregate all that data by name column, so each name must be a single line, x must be added, there must be added and in name of family and birthday column, the values can be taken randomly. In the finall I have a line with a name containing summed values of x and y column and the name of family and_birthday values can be picked at random. Examle how he shoul look for KRIS ROW:

KRIS | SIX | 546. 163. 2011 09-13

For KRIS SURNAME column value six was taken randomly from the SIX values, x and did the amount and value for the BIRTH_DAY column was taken at random dates 12-09-2011 and 2011-09-13.

I have no idea how I can do it.
May I ask for help?

Edited by: user13520646 2011-10-10 09:17

(not tested)

select name, min(surname), sum(x) , sum(y), min(birth_day)
 from table_name_not_provided
group by name;

Tags: Database

Similar Questions

  • How to develop and reduce lines or groups of lines in figures?

    How to develop and reduce lines or groups of lines in figures?

    Thank you

    Casey

    Select the rows (or columns):

    Then, place the cursor on one of the row headings (the numbers on the left):

    so that you see the carat facing downwards, then click here to bring up the context menu for the lines:

    then select "hide selected rows.

  • Grouping of lines - SQL Developer

    I was wondering if someone can help me here - Im trying to group the lines in a "package" to get fewer lines of data and group together the dates where they follow (and they have the same class of service and client ID). Im not the most irritable person so any help is appreciated.

    Here's my CREATE & INSERT

    CREATE TABLE ACF_SERVICES_DIM (Client_id varchar2 (20),)
    Date of Agreement_Start_date,
    Date of Agreement_End_Date,
    Service_Category Varchar2 (200),
    Agreement_id varchar2 (20));

    Insert into Acf_Services_Dim (Client_Id, Agreement_Start_Date, Agreement_End_Date, Service_Category, Agreement_Id)
    VALUES ('2607 ', 'J2849', 'Red', TO_DATE (' 01/10/2013 ',' dd/mm/yyyy'), NULL);

    Insert into Acf_Services_Dim (Client_Id, Agreement_Start_Date, Agreement_End_Date, Service_Category, Agreement_Id)
    VALUES ('2607 ', 'J2279', 'Red', TO_DATE (' 30/09/2013 ',' dd/mm/yyyy'), TO_DATE (' 01/03/2002 ',' dd/mm/yyyy'));

    Insert into Acf_Services_Dim (Client_Id, Agreement_Start_Date, Agreement_End_Date, Service_Category, Agreement_Id)
    VALUES ('2607 ', 'J2284', 'Red', TO_DATE (' 30/09/2013 ',' dd/mm/yyyy'), TO_DATE (' 01/03/2002 ',' dd/mm/yyyy'));

    Commit;

    The last two are of the same exact service type / id / dates etc so id expect to see a result... I think however it it link to 1 also, such as tracking the dates on and again, everything else is the same.

    If there is a 4th line-

    VALUES ('2607 ', 'J2299', 'Blue', TO_DATE (' 30/09/2013 ',' dd/mm/yyyy'), TO_DATE (' 01/03/2002 ',' dd/mm/yyyy'));

    Commit;

    I only expect to show also in a separate package because it does not match the 1st 3 because it is a different class of service, even if the dates are the same... I hope that helps?

    The request im trying to use is the following... HOWEVER it keeps giving me a not authorized windows error function

    WITH got_package_id AS

    (

    SELECT agreement_id

    MIN (CONNECT_BY_ROOT agreement_id) AS package_id

    Of acf_services_dim

    CONNECT BY NOCYCLE client_id = client_id PRIOR

    AND service_category = PRIOR service_category

    AND agreement_id <>agreement_id PRIOR

    AND (agreement_start_date = agreement_end_date FRONT + 1).

    OR agreement_end_date = PRIOR agreement_start_date - 1

    OR (agreement_start_date = PRIOR agreement_start_date

    AND agreement_end_date = PRIOR agreement_end_date

    )

    )

    GROUP BY agreement_id

    )

    SELECT s.Client_Id

    MIN (s.Agreement_Start_Date) AS package_start_date

    , NULLIF (NVL (MAX (s.Agreement_End_Date))

    DATE "9999-01-01'

    )

    DATE "9999-01-01'

    ) AS package_end_date

    s.Service_Category

    p.package_Id

    ROW_NUMBER () OVER (PARTITION BY s.client_id

    s.service_category

    ORDER BY p.package_id

    ) AS package_num - if wanted

    Of s acf_services_dim

    JOIN got_package_id p ON p.agreement_id = s.agreement_id

    GROUP BY s.client_id

    s.service_category

    p.package_id

    ;

    Don't know why, but im getting the following error when running in SQL developer... no idea why?

    Error in the command column line: 32:56

    Error report:

    SQL error: ORA-30483: window functions are not allowed here

    30483 00000 - "window functions are not allowed here."

    * Cause: Window functions are allowed only in the SELECT a query list.

    And, depending on the window cannot be an argument in another window or group

    function.

    * Action:

    Make a copy of your test case in a spreadsheet SQL Developer 4.0.3 connected to Oracle Xe (11.2.0.2) with jdk1.7.0_67 on Windows 7, everything works as expected:

    CLIENT_ID PACKAGE_START_DATE PACKAGE_END_DATE SERVICE_CATEGORY

    -------------------- ---------------------------------- ------------------------------- -------------------------------

    2607 1 March 02 13 - SEP - 30 Blue

    2607 1 March 02 13 - SEP - 30 Red

    No ORA-30483 at all.  What versions of SQL, Oracle DB, Java developer and so on are you using?

  • Trying to get ending entry into force for the groups of lines

    Hello world

    I searched the forums, but I can't find a post that is a problem quite like that.

    I have some data that looks like this:
            ID_NUM     EFFECTIVE ALLOC_PERCENT   ACCT
    ---------- --------- -------------   ----
           101 01-JUL-11            21   A1
           101 01-JUL-11            72   A2
           101 01-JUL-11             7   A3
    
           101 01-JUL-12            20   B1
           101 01-JUL-12            80   B2
    
           101 01-JAN-13            20   A1
           101 01-JAN-13            20   A2
           101 01-JAN-13            50   A3
           101 01-JAN-13            10   B1
    
           101 01-JUN-13            50   A1
           101 01-JUN-13            50   A2
    (note: I inserted manually empty lines for clarity)

    Here's the logic: the lines represent an assignment of percentage on the account for the identification number specified for this entry into force. A new date to cancel the previous, and if any line in the conceptual group is replaced, so they are all.

    I'll try to find the date when the effective period of each group ended and which includes in the game so that I can calculate then the number of days in a given line has been effective; something like that;
      ID_NUM     EFFECTIVE END_DATE   ALLOC_PERCENT ACCT
    ---------- --------- ---------- ------------- ----
           101 01-JUL-11 01-JUL-12             21 A1
           101 01-JUL-11 01-JUL-12             72 A2
           101 01-JUL-11 01-JUL-12              7 A3
    
           101 01-JUL-12 01-JAN-13             20 B1
           101 01-JUL-12 01-JAN-13             80 B2
    
           101 01-JAN-13 01-JUN-13             20 A1
           101 01-JAN-13 01-JUN-13             20 A2
           101 01-JAN-13 01-JUN-13             50 A3
           101 01-JAN-13 01-JUN-13             10 B1
    
           101 01-JUN-13 <null>                50 A1
           101 01-JUN-13 <null>                50 A2
    The end_date of the group is the EFFECTIVE_DATE of the next group (ordered by ID_NUM, EFFECTIVE_DATE).

    End_date of two rows is zero because there is no group of lines with an effective date the later - in my process, I'll NVL which sysdate so that my calculations of days will be valid.

    I tried some analytical queries with LEAD, but I couldn't figure out how to get the next date of the efficient group. I could get the entry into force of the next row, but not the next group. I couldn't specify how many lead lines to look forward, because there is not a number of rows in each group.

    How to fill the end_date column?

    Here's the code to create the above.
    create table t
    (id_num number,
     effective_date date,
     alloc_percent number,
     acct_code varchar2(4)
     );
    
    insert into t (id_num,Effective_date,alloc_percent,acct_code) values(101,'01-jul-2011',21.0,'A1');
    insert into t (id_num,Effective_date,alloc_percent,acct_code) values(101,'01-jul-2011',72.0,'A2'); 
    insert into t (id_num,Effective_date,alloc_percent,acct_code) values(101,'01-jul-2011',7.0,'A3');
    insert into t (id_num,Effective_date,alloc_percent,acct_code) values(101,'01-jul-2012',20.0,'B1');
    insert into t (id_num,Effective_date,alloc_percent,acct_code) values(101,'01-jul-2012',80.0,'B2');
    insert into t (id_num,Effective_date,alloc_percent,acct_code) values(101,'01-jan-2013',20.0,'A1');
    insert into t (id_num,Effective_date,alloc_percent,acct_code) values(101,'01-jan-2013',20.0,'A2');
    insert into t (id_num,Effective_date,alloc_percent,acct_code) values(101,'01-jan-2013',50.0,'A3');
    insert into t (id_num,Effective_date,alloc_percent,acct_code) values(101,'01-jan-2013',10.0,'B1');
    insert into t (id_num,Effective_date,alloc_percent,acct_code) values(101,'01-jun-2013',50.0,'A1');
    insert into t (id_num,Effective_date,alloc_percent,acct_code) values(101,'01-jun-2013',50.0,'A2');
    
    commit;
    
    select * from t;
    Oracle version information:
    Oracle Database 11 g Enterprise Edition Release 11.2.0.3.0 - 64 bit Production
    PL/SQL Release 11.2.0.3.0 - Production
    "CORE 11.2.0.3.0 Production."
    AMT for Solaris: 11.2.0.3.0 - Production Version
    NLSRTL Version 11.2.0.3.0 - Production


    Thank you very much

    Hello

    Here is one more way to do using lead work.

    WITH ds as (id_num, effective_Date, lead (effective_date) select on end_date (id_num order, effective_Date))

    t

    Id_num group, effective_date)

    Select t.*, ds.end_date

    DS, t

    where t.effective_Date = ds.effective_Date;

  • Type special group some lines

    Hey guys,.

    the time is the Dungeon running and there are still a few problems with my apex report, so I decied to ask fruther.

    I combine all my lines as in example 2 above. I know I could put the information corresponding to all, in the columns 'number', 'title' and 'project', for a line. I tried to use these solutions, but some of my entries in the last column "history" are a bit longer than usual of the. So my text cut to 32 k characters, because all the cells of a report are limited to 32 KB.

    Maybe it's important to know that the values of 'number', 'title' and 'project' could repeat sometimes.
    Now, I don't put all the information in my whole machted in a row. Each entry gets its own line.
    But you can see that the values for 'number', 'title' and 'project' always repeat and it is not should like this.

    Is it possible to group my lines, as in the 2.example?




    It looks like at the moment: (1. example)

    Number of... title... history of project...
    1... has... b.line1
    __________________________________
    1... has... b.line2
    __________________________________
    1... a... ab... ine3




    and so it should look like: (example 2)

    Number of... title... history of project...
    1... has... b.line1
    __________________________________
    ........................................ . Line2
    __________________________________
    ..........................................line3
    __________________________________
    2................b..........bb.........xxxx
    __________________________________
    ..........................................bbbb
    __________________________________

    (the points must be white space)

    and so on...



    Best regards
    wderr

    Hello wderr,

    Try this - it has no limitation on the number of columns to break down on:

    SELECT   DECODE(ROW_NUMBER() OVER (PARTITION BY num ORDER BY num), 1, num, '') num,
             DECODE(ROW_NUMBER() OVER (PARTITION BY num, title ORDER BY num, title), 1, title, '') title,
             DECODE(ROW_NUMBER() OVER (PARTITION BY num, title, project ORDER BY num, title, project), 1, project, '') project,
             history
      FROM   your_table;
    

    See the model? Just keep adding some "decode" columns for additional groups.

    Hope this helps,
    John

  • Contact groups 'multiply '...

    Hello!

    My groups of contacts 'multiply', on the day the day... I created one for each group was originally...

    Windows 10, Skype 7.21.85.100

    MOD Edit: Edited post to remove the information personal & consistent with the Skype community guidelines

    Hello and welcome to the Skype community,

    This problem is fixed in the latest version of Skype (7.22.x.104). You can download it here: Skype download (latest full)

    Hope that helps.

  • How to give users a group of line access to a voice mailbox using Cisco CM 8.5?

    Users who are part of the group line not to see when a message is left on the phone. Is there a way to associate the Group of curves with their voicemails?

    In the unit, it is called replacement extension.  This is the same problem solved by someone else

    https://supportforums.Cisco.com/discussion/11527831/MWI-alternate-extension

  • BI Publisher RTF model - fill a cell with a group without line breaks for each element

    I have a fairly rigid rtf model with multiple cells. A cell in particular just display a value of a single group.

    I want to display all the values of group in the cell, but instead of display each value on a new line of the

    cell and cell resizing, I need a way to repeat the values (we hope) without resizing the cell.

    Thus, for example, given a simple group such as < GROUP > < VALUE > where the GROUP contains the VALUES 1, 2, 3, 4 and 5.

    a normal <?-foreach: GROUP? > <? VALUE? > <? end foreach? > product

    CELL

    OUTPUT: 1

    2

    3

    4

    5

    What I would like is to be able to output the following (assume the slot size cell is not resized one appears exactly as it does in the rtf)

    CELL

    OUTPUT: 1 2 3

    4 5

    The tricky part is that I'd love to be able to have the text wrapping, once he arrives at the edge of the cell. Is there a simple way to do this?

    After a search in a dozen of nets beforehand of course, I find the answer, about 10 minutes after the announcement.

    Knew it was something simple!

  • How to spanne line / single called for a similar group of lines

    Hello

    I have a detail existing like that report, there is a conditional formatting on the cost, GP and safe etc..

    Type of mandate

    Type of assets

    Cost of the asset

    Term

    Grace period

    Deposit

    Future

    Vehicle

    1 173 952

    48

    0

    0% of the cost

    Future

    Vehicle

    4 173 952

    60

    0

    0% of the cost

    Future

    Vehicle

    1 500 000

    60

    0

    0% of the cost

    Future

    Material

    10,500,952

    48

    2

    10% of the cost

    Current

    Vehicle

    269 352

    36

    0

    0% of the cost

    Current

    Machines

    60,269,352

    48

    0

    0% of the cost

    Current

    Material

    200 000

    36

    0

    0% of the cost

    Current

    Material

    450 000

    36

    0

    0% of the cost

    Current

    Material

    250 000

    36

    0

    0% of the cost

    And we need to change the report at the start of this way without removing any existing conditional formatting.

    Type of mandate

    Type of assets

    Cost of the asset

    Term

    Grace period

    Deposit

    Current

    Vehicle

    269 352

    36

    0

    0% of the cost

    Machines

    60,269,352

    48

    0

    0% of the cost

    Material

    200 000

    36

    0

    0% of the cost

    Material

    450 000

    36

    0

    0% of the cost

    Material

    250 000

    36

    0

    0% of the cost

    Future

    Vehicle

    1 173 952

    48

    0

    0% of the cost

    Vehicle

    4 173 952

    60

    0

    0% of the cost

    Vehicle

    1 500 000

    60

    0

    0% of the cost

    Material

    10,500,952

    48

    2

    10% of the cost

    I tried many lines lasted , but without success, sometimes text out of the table or line covering the expected grouping. It is out of control for me

    Please help me, provide any sample/demo.

    Thank you

    I just tried according to your xml provided in post above, here is the model of form field and overview for your help.

    It's like you want.

    Type of mandate

    Type of assets

    Term

    Cost of the asset

    Grace period

    Deposit

    G V IF TERM_TYPE RS

    G V IF ASSET_TYPE RS

    G V IFTERMRS

    F ASSET_COST

    GRACE_PERIOD

    DEPOSIT E E E E

    Form fields

    G

    V

    IF

    TERM_TYPE

    RS

    G

    V

    IF

    ASSET_TYPE

    RS

    G

    V

    IF

    TERM

    RS

    F

    ASSET_COST

    GRACE_PERIOD

    DEPOSIT

    E

    E

    E

    E

    Overview

    Type of mandate

    Type of assets

    Term

    Cost of the asset

    Grace period

    Deposit

    Current

    Material

    36

    200 000

    0

    0% of the cost

    450 000

    0

    0% of the cost

    250 000

    0

    0% of the cost

    Machines

    48

    60,269,352

    0

    0% of the cost

    Vehicle

    36

    269 352

    0

    0% of the cost

    Future

    Material

    48

    10,500,952

    2

    10% of the cost

    Vehicle

    48

    1 173 952

    0

    0% of the cost

    60

    4 173 952

    0

    0% of the cost

    1 500 000

    0

    0% of the cost

    Note: as you mentioned earlier, it is a conditional formatting and logic on the existing model, these must be change as field are group / nested group, you may need to set field with current - group)

  • Grouping of lines from common lines in detail header

    Hello

    I have two tables TAB_MST and TAB_DTL with the information as below:

    {code}

    CREATE TABLE TAB_MST
    (
    NUMBER OF MSTCOL
    )
    /

    ALTER TABLE TAB_MST ADD CONSTRAINT TAB_MST_PK PRIMARY KEY (MSTCOL)
    /

    INSERT INTO TAB_MST (MSTCOL) VALUES (1);
    INSERT INTO TAB_MST (MSTCOL) VALUES (2);
    INSERT INTO TAB_MST (MSTCOL) VALUES (3);
    INSERT INTO TAB_MST (MSTCOL) VALUES (4);

    CREATE TABLE TAB_DTL
    (
    NUMBER OF MSTCOL
    NUMBER OF DTLCOL
    )
    /

    ALTER TABLE TAB_DTL ADD CONSTRAINT TAB_DTL_PK PRIMARY KEY (MSTCOL, DTLCOL)
    /

    INSERT INTO TAB_DTL (MSTCOL, DTLCOL) VALUES (1, 1);
    INSERT INTO TAB_DTL (MSTCOL, DTLCOL) VALUES (1, 2);
    INSERT INTO TAB_DTL (MSTCOL, DTLCOL) VALUES (1, 3);
    INSERT INTO TAB_DTL (MSTCOL, DTLCOL) VALUES (1, 4);
    INSERT INTO TAB_DTL (MSTCOL, DTLCOL) VALUES (1, 5);
    INSERT INTO TAB_DTL (MSTCOL, DTLCOL) VALUES (2, 4);
    INSERT INTO TAB_DTL (MSTCOL, DTLCOL) VALUES (2, 7);
    INSERT INTO TAB_DTL (MSTCOL, DTLCOL) VALUES (2, 8);
    INSERT INTO TAB_DTL (MSTCOL, DTLCOL) VALUES (2, 9);
    INSERT INTO TAB_DTL (MSTCOL, DTLCOL) VALUES (3, 8);
    INSERT INTO TAB_DTL (MSTCOL, DTLCOL) VALUES (3, 9);
    INSERT INTO TAB_DTL (MSTCOL, DTLCOL) VALUES (3, 10);
    INSERT INTO TAB_DTL (MSTCOL, DTLCOL) VALUES (3, 11);
    INSERT INTO TAB_DTL (MSTCOL, DTLCOL) VALUES (4, 12);
    INSERT INTO TAB_DTL (MSTCOL, DTLCOL) VALUES (4, 13);
    INSERT INTO TAB_DTL (MSTCOL, DTLCOL) VALUES (4, 14);

    COMMIT;

    {code}

    I want to group the rows in the Master table (TAB_MST) to different groups based on the data in the secondary table (TAB_DTL) with output like below

    MSTCOL GROUPID
    1               1
    2               1
    3               1
    4               2

    Rule for grouping are as follows:

    (1) if there is a common value of DTLCOL for two different values of MSTCOL, then two MSTCOL values should be grouped under the same group, for example for the above case of sample
    DTLCOL (value = 4) is common for MSTCOL = 1 and MSTCOL = 2, so MSTCOL 1 and MSTCOL 2 belong to the same group (GROUPID = 1).
    DTLCOL (value = 8, 9) is common for MSTCOL = 2, MSTCOL = 3, so 3 MSTCOL must belong to the same group as MSTCOL 2 (GROUPID = 1)
    There is no common value of DTLCOL for MSTCOL = 4, so it is in a separate group.

    Here is the PL/SQL block to highlight this grouping behavior. Two temporary tables are created to achieve this:

    {code}

    CREATE TABLE TAB_MST_GROUP
    (
    NUMBER OF MSTCOL
    GROUPID NUMBER
    )
    /

    CREATE TABLE TAB_TMP_GROUP
    (
    GROUPID NUMBER
    )
    /


    DECLARE
    CURSOR c1
    IS
    SELECT * FROM tab_mst;

    prevmstcol NUMBER;
    prevgroupid NUMBER: = 1;
    vtmpgroupid NUMBER;
    BEGIN
    DELETE tab_mst_group;

    FOR r1 IN c1
    LOOP
    IF prevmstcol IS NULL
    THEN
    INSERT INTO tab_mst_group
    VALUES (r1.mstcol, prevgroupid);

    prevmstcol: = r1.mstcol;
    ON THE OTHER
    INSERT INTO tab_tmp_group
    SEPARATE SELECT GroupID
    OF tab_mst_group a, tab_dtl b, tab_dtl c
    WHERE a.mstcol = b.mstcol
    AND c.dtlcol = b.dtlcol
    AND c.mstcol = r1.mstcol;

    IF SQL % ROWCOUNT = 0
    THEN
    prevgroupid: = prevgroupid + 1;

    INSERT INTO tab_mst_group
    VALUES (r1.mstcol, prevgroupid);
    ON THE OTHER
    SELECT MIN (groupid) IN the vtmpgroupid OF tab_tmp_group;

    UPDATE tab_mst_group
    SET groupid = vtmpgroupid
    WHERE groupid IN (SELECT tab_tmp_group FROM groupid);

    INSERT INTO tab_mst_group
    VALUES (r1.mstcol, vtmpgroupid);

    SELECT MAX (groupid) IN tab_mst_group prevgroupid;

    DELETE tab_tmp_group;
    END IF;
    END IF;
    END LOOP;
    END;

    {code}


    Question:

    a. can achieve us in SQL instead of PL/SQL?
    b. fresh general reading of TAB_DTL grows exponentially if the number of cases in TAB_MST develops. How can we reduce the number of TAB_DTL reading as the real lines of TAB_DTL is very high.


    Thank you
    sukhijank

    Hi, Sukhijank,

    Thanks for the additional information.  Has not only learned these details since posting your first message, did you?  If you post information like that in your first post, and then people can use it to give you a better response to the first answer.

    The idea I had for a recursive solution of WITH clause will not work after all.

    I think that the best solution will be in PL/SQL, using a table like tab_mst_group that you posted, but with an extra column:

    CREATE TABLE TAB_MST_GROUP
    (
      mstcol NUMBER PRIMARY KEY,
      groupid   NUMBER,
      levelnum NUMBER
    );
    CREATE INDEX tab_mst_group_groupid_levelnum
    ON     tab_mst_group (levelnum, groupid);
    

    If llevelnum = 0, which means that the allocation of groupid is not certain; If levelnum > 0, then groupid is correct.

    Here is a procedure you can use to fill in the table:

    CREATE OR REPLACE PROCEDURE tab_mst_group_populate
    AS
        new_groupid  tab_mst_group.groupid%TYPE
         := 0;
        new_levelnum tab_mst_group.levelnum%TYPE;
        num_added  PLS_INTEGER;
        truncate_stmt VARCHAR2 (50) := 'TRUNCATE TABLE tab_mst_group';
    BEGIN
        --  *****  Remove old entries from the table  *****
        -- dbms_output.put_line (truncate_stmt || ' = truncate_stmt in tab_mst_group_populate'); -- Debugging
        EXECUTE IMMEDIATE  truncate_stmt;
    
        --  *****  Populate table with all mstcols, and 1-member groups  *****
        INSERT INTO  tab_mst_group (mstcol, groupid, levelnum)
        SELECT    m.mstcol
        ,       m.mstcol  AS groupid
        ,       MIN ( CASE
                         WHEN  o.mstcol IS NULL
         THEN  1
         ELSE  0
                     END
        )  AS lvlnum
        FROM     tab_mst    m
        LEFT JOIN tab_dtl    d ON  d.mstcol = m.mstcol
        LEFT JOIN tab_dtl    o ON  o.dtlcol = d.dtlcol
                AND o.mstcol   != d.mstcol
        GROUP BY    m.mstcol;
    
        --  ***** Get groupid for lowest mstcol that still needs one  *****
        WHILE  new_groupid IS NOT NULL
        LOOP
            SELECT  MIN (groupid)
    INTO new_groupid
    FROM tab_mst_group
    WHERE levelnum = 0;
    IF  new_groupid   IS NOT NULL
    THEN
         --  ***  Confirm groupid for this one mstcol  ***
         UPDATE  tab_mst_group
         SET     levelnum = 1
         WHERE   levelnum = 0
         AND     groupid = new_groupid;
         new_levelnum := 2;
         num_added := 1;
         --  ***  Add neighboring mstcols to this group  ***
    
         WHILE  num_added > 0
         LOOP
             UPDATE  tab_mst_group
      SET groupid   = new_groupid
      , levelnum  = new_levelnum
      WHERE levelnum  = 0
      AND groupid   IN (
                       SELECT  d2.mstcol
                FROM  tab_mst_group g1
          JOIN  tab_dtl       d1  ON  d1.mstcol  = g1.mstcol
          JOIN  tab_dtl       d2  ON  d2.dtlcol  = d1.dtlcol
                        AND d2.mstcol != d1.mstcol
          JOIN  tab_mst_group g2  ON  g2.mstcol  = d2.mstcol
          WHERE  g1.levelnum  = new_levelnum - 1
          AND  g1.groupid   = new_groupid
          AND  g2.levelnum  = 0
             );
      num_added := SQL%ROWCOUNT;
      dbms_output.put_line (num_added || ' = num_added');
             new_levelnum := new_levelnum + 1;
         END LOOP;
    END IF;
        END LOOP;
    
    END tab_mst_group_populate;
    /
    SHOW ERRORS
    

    The basic strategy is that we start assuming that each mstcol will have its own groupid.  The CASE expression in the INSERT statement sets levelnum = 1 for the mstcols that do not exist in the tab_dtl table, or are not related to other mstcols in tab_dtl.  The loop after that looks like for tab_mst_group lines are always 0, which means that the grpupid must still be confirmed or changed.  He begins by finding the lowest mstcol which still has levelnum = 0 and makes a new group.  The inner loop looking for related mstcols and the brand as being in the same group.

    You could combine tab_mst and tab_mst_group; I see no need to have a separate table (but maybe do you).  If combine you them, then you would not truncate the table in the procedure.

  • Ventilation-grouping EIP without hard coding provider systems

    Hello

    I am currently working on the best way to create a service that follows the model of grouping of point clouds.
    http://camel.Apache.org/scatter-gather.html

    The problem is that I can't encode hard the BPEL service provider. (There may be a large number of them).

    Instead, I want that they subscribe to a JMS topic and send the responsere to a JMS queue. If the service applicant waits a predetermined time before to pick up all the answers of the queue, it would work. Unfortunately the JMS adapter dosen't support pick up messages form the JMS queue on request.

    I have plans to replace the JMS queue with a database table, and theoretically it would work - but seems complex.

    I have also reviewed all simply by using a correlated response service. Service applicant would be able to handle a response in time, but the Providors can be configured to retry mutiple times. It won't scale well if there are 10 or more systems software.

    Is there a simple way to achieve what I'm trying to do that I'm missing?

    Robert

    How do you write java code to use the jms api synchronously read the queue.

    http://docs.Oracle.com/javaee/1.4/tutorial/doc/JMS5.html
    http://docs.Oracle.com/javaee/1.4/tutorial/examples/JMS/simple/src/SimpleSynchConsumer.Java

  • Group 4 lines in one line

    Using this Oracle database version:

    Oracle Database 11 g Enterprise Edition Release 11.2.0.3.0 - 64 bit Production

    WITH tbl_data AS
    (
    SELECT 19352640 bug_number, 'Patch: 18285590' patch_abstract, 'fpa' app FROM DUAL UNION ALL
    SELECT 19352640, 'Patch: 18285590', 'gms' FROM DUAL UNION ALL
    SELECT 19352640, 'Patch: 18285590', 'pa' FROM DUAL UNION ALL
    SELECT 19352640, 'Patch: 18285590', 'pji' FROM DUAL
    )
    SELECT * FROM tbl_data;
    

    Returns the following:

    BUG_NUMBER PATCH_ABSTRACT  APP
    ---------- --------------- ---
      19352640 Patch: 18285590 fpa
      19352640 Patch: 18285590 gms
      19352640 Patch: 18285590 pa 
      19352640 Patch: 18285590 pji
    
    4 rows selected.
    

    I was wondering if it would be possible to generate this output instead:

    BUG_NUMBER PATCH_ABSTRACT  APP
    ---------- --------------- ------------------
      19352640 Patch: 18285590 fpa, gms, pa, pji
    

    Can I use PIVOT? I had a look at some examples PIVOT, but it seems that this must include some sort of aggregation as a SUM or COUNT function?

    Any advice much appreciated.

    Thank you

    You can use the LISTAGG function:

    WITH tbl_data AS
    (
    SELECT 19352640 bug_number, 'Patch: 18285590' patch_abstract, 'fpa' app FROM DUAL UNION ALL
    SELECT 19352640, 'Patch: 18285590', 'gms' FROM DUAL UNION ALL
    SELECT 19352640, 'Patch: 18285590', 'pa' FROM DUAL UNION ALL
    SELECT 19352640, 'Patch: 18285590', 'pji' FROM DUAL
    )
    SELECT bug_number, patch_abstract, LISTAGG(app, ', ')
             WITHIN GROUP (ORDER BY app) "APP_LIST" FROM tbl_data
             group by bug_number,patch_abstract;
    

    OUTPUT:

    19352640 Patch: 18285590 FPA, gms, pa, pji

    For more information: LISTAGG

  • Need help to build the query to group the lines

    Hello all, hope someone can help me with this. I am working in Oracle 11 g PL/SQL 11.2.0.2.0.

    I have the following query, which does exactly what I need, but I have been invited to consolidate the results in a specific way and I can't do that. First of all the existing request:
    SELECT facility_id
    ,facility_type
    ,COUNT (CASE WHEN component_type = 'ATTACH2NDPARTY' THEN 1 END) AS ATTACH2NDPARTY
    ,COUNT (CASE WHEN component_type = 'ATTACH3RDPARTY' THEN 1 END) AS ATTACH3RDPARTY
    ,COUNT (CASE WHEN component_type = 'BREAKERGT' THEN 1 END) AS BREAKERGT
    ,COUNT (CASE WHEN component_type = 'BREAKERUSS' THEN 1 END) AS BREAKERUSS
    ,COUNT (CASE WHEN component_type = 'CAPACIFORMER' THEN 1 END) AS CAPACIFORMER
    ,COUNT (CASE WHEN component_type = 'CAPACITOR' THEN 1 END) AS CAPACITOR
    ,COUNT (CASE WHEN component_type = 'CEFIBEROPTIC' THEN 1 END) AS CEFIBEROPTIC
    ,COUNT (CASE WHEN component_type = 'ELASTIDISCONN' THEN 1 END) AS ELASTIDISCONN
    ,COUNT (CASE WHEN component_type = 'NETWORKPROTECT' THEN 1 END) AS NETWORKPROTECT
    ,COUNT (CASE WHEN component_type = 'POLE' THEN 1 END) AS POLE
    ,COUNT (CASE WHEN component_type = 'REACTOR' THEN 1 END) AS REACTOR
    ,COUNT (CASE WHEN component_type = 'RECLOSER3PUPOIL' THEN 1 END) AS RECLOSER3PUPOIL
    ,COUNT (CASE WHEN component_type = 'RECLOSERTSUP' THEN 1 END) AS RECLOSERTSUP
    ,COUNT (CASE WHEN component_type = 'RECLSR3PCNTRL3A' THEN 1 END) AS RECLSR3PCNTRL3A
    ,COUNT (CASE WHEN component_type = 'RECLSR3PCNTRLNT' THEN 1 END) AS RECLSR3PCNTRLNT
    ,COUNT (CASE WHEN component_type = 'RECLSRTSCNTRL' THEN 1 END) AS RECLSRTSCNTRL
    ,COUNT (CASE WHEN component_type = 'RECTIFIERUSS' THEN 1 END) AS RECTIFIERUSS
    ,COUNT (CASE WHEN component_type = 'REGULATORJOINT' THEN 1 END) AS REGULATORJOINT
    ,COUNT (CASE WHEN component_type = 'REGULATOROH' THEN 1 END) AS REGULATOROH
    ,COUNT (CASE WHEN component_type = 'REGULATORUSS' THEN 1 END) AS REGULATORUSS
    ,COUNT (CASE WHEN component_type = 'RMS' THEN 1 END) AS RMS
    ,COUNT (CASE WHEN component_type = 'SPLICEPRIMARY' THEN 1 END) AS SPLICEPRIMARY
    ,COUNT (CASE WHEN component_type = 'STREETLIGHT' THEN 1 END) AS STREETLIGHT
    ,COUNT (CASE WHEN component_type = 'SWITCHSCADA' THEN 1 END) AS SWITCHSCADA
    ,COUNT (CASE WHEN component_type = 'TAPCHANGER' THEN 1 END) AS TAPCHANGER
    ,COUNT (CASE WHEN component_type = 'TRAFFICSIGNAL' THEN 1 END) AS TRAFFICSIGNAL
    ,COUNT (CASE WHEN component_type = 'TRANSF480' THEN 1 END) AS TRANSF480
    ,COUNT (CASE WHEN component_type = 'TRANSFGROUND' THEN 1 END) AS TRANSFGROUND
    ,COUNT (CASE WHEN component_type = 'TRANSFISOLATION' THEN 1 END) AS TRANSFISOLATION
    ,COUNT (CASE WHEN component_type = 'TRANSFOH' THEN 1 END) AS TRANSFOH
    ,COUNT (CASE WHEN component_type = 'TRANSFUG' THEN 1 END) AS TRANSFUG
    ,COUNT (CASE WHEN component_type = 'TRANSFURD' THEN 1 END) AS TRANSFURD
    ,COUNT (CASE WHEN component_type = 'TRANSFUSS' THEN 1 END) AS TRANSFUSS
    FROM (SELECT fy.id AS facility_id
          ,fy.external_facility_id
          ,fy.flty_facility_type as facility_type
          ,cp.cpty_component_type as component_type
          FROM facilities fy
          LEFT OUTER JOIN components cp
          ON cp.facility_id= fy.id
          ORDER BY fy.id DESC)
    GROUP BY facility_id, facility_type
    I was asked to do, is to display a number of facility_type who have each of the combinations of the 'DEAL' 33 areas. Installation types are strings. So an expected result would look something like:

    FACILITY_TYPE | ATTACH2NDPARTY | ATTACH3RDPARTY | BREAKERGT | ... TRANSFUSS | COUNTY
    MANHOLE X X 10
    MANHOLE X X 22
    POLE X X 5

    and so on. Because there are 33 BUSINESS areas and therefore 33! possible combinations, I was thinking about a sort of loop would achieve the desired result, but I'm stuck and could really use a shot in the arm. Any help will be appreciated and obtained points! Thanks in advance.
    select
     facility_type
    ,ATTACH2NDPARTY
    ,ATTACH3NDPARTY
    -- and so on
    , count(*) cnt
    from (
    --your query
    SELECT facility_id
    ,facility_type
    ,COUNT (CASE WHEN component_type = 'ATTACH2NDPARTY' THEN 1 END) AS ATTACH2NDPARTY
    ,COUNT (CASE WHEN component_type = 'ATTACH3RDPARTY' THEN 1 END) AS ATTACH3RDPARTY
    ,COUNT (CASE WHEN component_type = 'BREAKERGT' THEN 1 END) AS BREAKERGT
    ...
    )
    group by
     facility_type
    ,ATTACH2NDPARTY
    ,ATTACH3NDPARTY
    -- and so on like in projection
    
  • Assign the different number to each different group of lines

    Hello
    I have a simple request, but I can't find any solution.

    I would attribute the different sequence number to each different group of my results.

    My goal is the following:

    http://img10.imageshack.us/img10/51/obieeseqnumbertogroup.jpg

    I tried RCOMPTE, C.V. etc... but without success...

    Can you help me with this?

    Hello

    You can try the steps below to get what you are looking for:

    -Assuming that your criteria has these columns date, the worker and the group. Create another column with fx as rcount (group) and apply the sort on the column group in the application type tab is necessary to generate counts of sequence based on the criteria group.
    -Then apply different conditional formatting on this new column.
    -Now in the pivot put this new column in the measure, the worker column into rows and columns date column. You should get an output according to the image displayed by you earlier.
    -If you must also sort either worker or date column, do it in pivot view, not in the criteria tab.

    I hope this helps!

    Thank you

  • Detect connected lines

    I'm trying to understand the best way to do something.  It is led in TestStand using Switch Executive.

    I have a line of 213 column x 4 2-wire Matrix.  4 rows connect up to 4-channel PXI-5105.  I've defined logical names for each column to go to each of r0, r1, r2 and r3.  Users will choose up to 4 in the columns of 213 to route to the 5105 for sampling. If a user connects 4 channels and then decide they want to try a different channel, I wish I could disconnect only 1 channel, they no longer want and connected to the new channel.  I've defined groups of road called All_To_R0, All_To_R1, etc., with the idea that if the user wants to exchange the R0 channel then I would call an offset on the All_To_R0 who will ensure that what it is related to R0 disconnects and then I plug the new channel.

    However, this generates errors saying roads do not exist, which makes sense, I guess.  I could just call a DisconnectAll and let my users to follow with routes they want to connect.  I could follow this in my driver code but / puts an end to demolitions would stop me to manage accurately the State of the switch.  Is there an 'integrated' way to do?

    To know if a road is connected or not, you can call FindRoute on a NISE session. It's a way to do it, but you need to understand what are the endpoints of a route. You can use the API configuration NISE to understand what roads are part of a group of lines, and what are the endpoints for a given road, if you are not comfortable to hardcode these channel names in your program.

    Another way to determine if the road is connected or not, especially if your end goal is to disconnect, is to call Disconnect on this road and ignore the error indicating that the road did not exist. (You can always capture other errors, however).

Maybe you are looking for

  • A100 replacement hard drive

    I saw the other posts on this but no definitive answer.My HARD drive is dying and needs to be replaced. I see the posotion from the LHS is under the Palm drive and there seems to be one removable flap - other posts say there is only one screw to remo

  • Replace the HD Ideapad y500 recommendation

    I just bought the IdeaPad Y500 and seeks to replace the hard drive for the moment because I'm not ready for windows 8. I thought that it would just be easier to replace the drive to try to save... Problems using Hitachi Travelstar GST 0S 03563 1 TB 7

  • How can I reference the properties of a control in a cluster in an array of clusters?

    Hello I am a newbie of Labview, so any advice is welcome on any code posted here. I have one "tick" test VI where the operator is required to boxes that are then "signed". Once all the boxes are signed correctly, the operator indicates that they are

  • spittoon

    Very well. Had to buy for my H470 spittoon. Received today. Why is there no instructions accompanying the replacement part? Where they would be?

  • LENOVA IBM THINKPAD DOES NOT CONNECT TO INTERNET

    I have a treadmill thinking Lenova T60 IBM and it does not connect to my home network secure wireless. I have other laptops (MAC and DELL) which are connect well but my IBM will not find all networks in range, no matter how many times I have updated