FETCH ONE RECORD IN THE SECOND TABLE OF CORRELATED SUB QUERY

Hi all

I have provided the script below, I want to single fecth record in the second table in the join query,

based on the example below, I want to go get one record of the table emp2 what matches with the emp_id of table emp1, please note emp2 may contain more record for the emp_id emp1 which respects

all records can be selected in the table emp2.

DROP TABLE emp1.

CREATE TABLE emp1 (emp_id NUMBER);

INSERT INTO emp1 VALUES (1);

INSERT INTO emp1 VALUES (2);

COMMIT;

DROP TABLE emp2.

CREATE TABLE emp2 (emp_id NUMBER, emp_name VARCHAR2 (100));

INSERT INTO emp2 VALUES (1, 'Name1');

INSERT INTO emp2 VALUES (2, 'Name2');

INSERT INTO emp2 VALUES (1, 'Name3');

INSERT INTO emp2 VALUES (2, 'Conjoint4');

COMMIT;

SELECT * from emp1.

SELECT * from emp2.

SELECT T1. EMP_ID, MIN (T2. EMP_NAME)

FROM EMP1, EMP2 T2 T1

WHERE T1. EMP_ID = T2. EMP_ID

GROUP T1. EMP_ID;

My output should be the same as the result set of query above, but I don't want this logic, please provide the solution by using a different logic, thanks in advance.

2811876 wrote:

Thanks for your comments :-)

My business logic will change to 'Fetch N second timeline table', that's the reason why I asked for a different approach, if I use max, min to achieve this does not allow me to evolve dynamically.

Although logic has not been expressed at all in your original question, so good job I asked.

You could do something like:

SQL > ed
A written file afiedt.buf

1 with emp1 (select 1 as the emp_id of union double all the)
2. Select 2 double
3               )
4, emp2 (select 1 as emp_id, 'name 1' as emp_name double union all
5. Select "name 2' Union double every 2
6 select 1, 'name' 3' from dual union all
7. Select 2, 'name 4' double union all.
8 select 1, 'name 5' from dual union all '.
9 select 2, 'name 6' from dual '.
10               )
11-
12. end of test data
13-
14 select emp_id, emp_name
15 of)
16 select t1.emp_id, t2.emp_name
17, row_number() over (partition by order of t2.emp_name t1.emp_id) rn
emp1 t1 18
19 join t2 emp2 (t1.emp_id = t2.emp_id)
20       )
21 * where rn<=>
SQL > /.

Enter the value for rows_required: 1
21 Alumni: where rn<=>
21 news: where rn<=>

EMP_ID EMP_NA
---------- ------
1 name 1
2 name 2

SQL > /.
Enter the value for rows_required: 2
21 Alumni: where rn<=>
21 news: where rn<=>

EMP_ID EMP_NA
---------- ------
1 name 1
1 name 3
2 name 2
2 name 4

Tags: Database

Similar Questions

  • Insert the record in the second table by making the trigger on the first table

    I hv created 2 tables as shown below the code sql. I want to insert some record (line current value) column of the first table, next sequence value and sysdate into second table. I hv created trigger but I gave warning.
    so I want to know what is the problem in my sql code.
    Pls correct!

    SQL > create table myuser1 (u_id varchar2 (10), uname varchar2 (20), sex char(1));

    SQL > create table myuser2 (reg_no number (5), reg_date Date, u_id varchar2 (20));

    SQL > create the sequence myuser2_seq;

    SQL > alter table myuser1 add constraint pk_myuser1 key (u_id) primary;

    SQL > alter table myuser2 add constraint pk_myuser2 key (reg_no) primary;

    SQL > CREATE TRIGGER MYTRIGGER
    2 AFTER INSERT ON myuser1
    3 FOR EACH LINE
    4 BEGIN
    5 INSERT INTO myuser2 (reg_no, reg_date, u_id)
    6 VALUES (myuser2_seq.nextval, SELECT SYSDATE FROM DUAL, select u_id myuser)
    1)
    7 END;
    8.

    WARNING: Trigger created with compilation errors.

    JKMourya wrote:
    I hv created 2 tables as shown below the code sql. I want to insert some record (line current value) column of the first table, next sequence value and sysdate into second table. I hv created trigger but I gave warning.
    so I want to know what is the problem in my sql code.
    Pls correct!

    SQL > create table myuser1 (u_id varchar2 (10), uname varchar2 (20), sex char(1));

    SQL > create table myuser2 (reg_no number (5), reg_date Date, u_id varchar2 (20));

    SQL > create the sequence myuser2_seq;

    SQL > alter table myuser1 add constraint pk_myuser1 key (u_id) primary;

    SQL > alter table myuser2 add constraint pk_myuser2 key (reg_no) primary;

    SQL > CREATE TRIGGER MYTRIGGER
    2 AFTER INSERT ON myuser1
    3 FOR EACH LINE
    4 BEGIN
    5 INSERT INTO myuser2 (reg_no, reg_date, u_id)
    6 VALUES (myuser2_seq.nextval, SELECT SYSDATE FROM DUAL, select u_id myuser)
    1)
    7 END;
    8.

    WARNING: Trigger created with compilation errors.

    SELECT inside VALUES clause is NOT allowed.
    do SELECT statements before the INSERT command

  • Using JOIN to two tables to find records in the second table...

    I always seem to get these types of queries wrong and need a bit of help:

    I have a MARKETER_ACCOUNT relationship table and another table of pending relationships called ACCOUNT_ENROLLMENT.

    I have accounts that can register with a MARKETING agent. They enter the table ACCOUNT_ENROLLMENT pending and a certain Effective Date the active go and then move to the MARKETER_ACCOUNT table. If a relationship ends, it can end in any event if registering with another buyer or if no registration pending they are supposed to be going back to the parent company.

    So I want to find all the records that came back to the parent company (that is, they may not have a case pending in the ACCOUNT_ENROLLMENT of the table, but have an end date in the MARKETER_ACCOUNT table):

    Select * MARKETER_ACCOUNT m
    where M.account_no NOT IN (select E.account_no from ACCOUNT_ENROLLMENT E
    where E.effective_date between 8 December 2009 "-January 7, 2010")
    and M.expiration_date between 8 December 2009 "-January 7, 2010;

    This request is still in progress, and I don't know where I am going wrong. I mean GIVE me all the accounts in the table MARKETER_ACCOUNT that have a date of expiry from December 7, 2009 "-January 7, 2010 ' and where these accounts are NOT pending in the ACCOUNT_ENROLLMENT table, where the entry into force is for the same period."

    Any help would be greatly appreciated.

    Sean

    Perhaps you could try the version NOT EXISTS in the query:

    SELECT  *
    FROM    MARKETER_ACCOUNT M
    WHERE   NOT EXISTS
            (
                    SELECT  NULL
                    FROM    ACCOUNT_ENROLLMENT E
                    WHERE   M.ACCOUNT_NO = E.ACCOUNT_NO
                    AND     E.EFFECTIVE_DATE BETWEEN TO_DATE('08-DEC-2009','DD-MON-YYYY') AND TO_DATE('07-JAN-2010','DD-MON-YYYY')
            )
    AND     M.EXPIRATION_DATE BETWEEN TO_DATE('08-DEC-2009','DD-MON-YYYY') AND TO_DATE('07-JAN-2010','DD-MON-YYYY');
    

    If not, check out these discussions:

    {message: id = 1812597}

    {: identifier of the thread = 863295}

  • Nested table of object type have only one record all the time

    Hi all

    I have a question regarding the storage of multiple records in a nested Table that is of type OBJECT.

    The program below that I wrote for the test and during the test, I was able to store only the last record in the nested Table.

    Please let me know what I did wrong here.

    Step 1:
    CREATE or REPLACE TYPE book_obj AS OBJECT (name varchar2 (25), author varchar2 (25), abstract varchar2 (4000));
    /

    Step 2:
    CREATE or REPLACE TYPE book_table IS TABLE OF THE book_obj;
    /

    Step 3: CREATE TABLE book (name, varchar2 (25), varchar2 (25) author, varchar2 (4000)) abstract;
    INSERT VALUES Accountants ('Harry Potter,' 'MK', 'It's magic');
    INSERT the book VALUES ("Ramayana', 'VK', 'It is mythiology'");
    COMMIT;

    Step 4:
    declare
    bookset book_table;
    ln_cnt pls_integer;
    Start
    bookset: = book_table (book_obj ('madhu', 'kongara', 'sudhan'));
    dbms_output.put_line (' the number is ' | bookset.) (Count); -> I see COUNT = 1
    bookset: = bookset_t(); -> Assignment to NULL.
    dbms_output.put_line (' the number is ' | bookset.) (Count); -> I see County 0
    for rec in (select * from book) loop-> now a loop twice.
    dbms_output.put_line (' name > ' |) Rec.Name);
    bookset: = bookset_t (book_t (rec.name, rec.author, rec.abstract));
    end loop;
    dbms_output.put_line (' the number is ' | bookset.) (Count); -> I can see COUNT = 1 (why?)
    END;

    I looped twice to fill two records in the TABLE IMBRIQUEE OF TYPE OBJECT. But when I see the Count I get only 1 and the data is also having the last record.

    Can you get it someone please let me know how to fill out the table nested with all records. Tell me where I am wrong.

    Very much appreciate your help here.

    Thank you and best regards,
    NKM

    Maldini says:
    dbms_output.put_line (' the number is ' | bookset.) (Count); -->, I can see COUNT = 1 (why?)

    Because instead of add to bookset collectionto set (ergo replacement) it a collection containing recovered book. Use:

    declare
        bookset book_table;
        ln_cnt pls_integer;
    begin
        bookset := book_table(book_obj('madhu','kongara','sudhan'));
        dbms_output.put_line('The count is '||bookset.count); --> I can see COUNT =1
        bookset := book_table(); --> Assigning back to NULL.
        dbms_output.put_line('The count is '||bookset.count); --> I can see count as 0
        for rec in (select * from book) loop --> Now Looping two times.
          dbms_output.put_line(' name > '||rec.name);
          bookset.extend;
          bookset(bookset.count) := book_obj(rec.name, rec.author, rec.abstract);
        end loop;
        dbms_output.put_line('The count is '||bookset.count); --> I can see COUNT =1 (why)
    end;
    /
    The count is 1
    The count is 0
    name > Harry Potter
    name > Ramayana
    The count is 2
    
    PL/SQL procedure successfully completed.
    
    SQL> 
    

    Or better use bulk collect:

    declare
        bookset book_table;
        ln_cnt pls_integer;
    begin
        bookset := book_table(book_obj('madhu','kongara','sudhan'));
        dbms_output.put_line('The count is '||bookset.count); --> I can see COUNT =1
        bookset := book_table(); --> Assigning back to NULL.
        dbms_output.put_line('The count is '||bookset.count); --> I can see count as 0
        select  book_obj(name,author,abstract)
          bulk collect
          into  bookset
          from  book;
        for i in 1..bookset.count loop --> Now Looping two times.
          dbms_output.put_line(' name > '||bookset(i).name);
        end loop;
        dbms_output.put_line('The count is '||bookset.count); --> I can see COUNT =1 (why)
    end;
    /
    The count is 1
    The count is 0
    name > Harry Potter
    name > Ramayana
    The count is 2
    
    PL/SQL procedure successfully completed.
    
    SQL> 
    

    SY.

  • Try to get a collection of frames of texts related with the second table in my document

    Hi all

    There are two long tables in my document, and I want to do is to get the collection of blocks of text that contain the second table to resize (single height),

    and set the number of columns to 3 columns and column gutter to 0, but I am unable to get the collection of blocks of text that contains the second table.

    I also want to apply a different master page to the pages that contain the second table.

    I know that I can change my number of columns and the gutter using script below, but the thing is I don't want the script to assign my first table,

    and I can not also put the tables in separate the file because there are cross-references.

    Script to change the gutter and the number of columns

    app.findObjectPreferences.textColumnCount = 1;

    app.changeObjectPreferences.textColumnCount = 3;

    App.Documents.Item (0) .changeObject ();

    app.findObjectPreferences.textColumnGutter! = 0 ;

    app.changeObjectPreferences.textColumnGutter = 0;

    App.Documents.Item (0) .changeObject ();

    I'm new to javascript and I searched for solutions for several days, but still can not find how to get it work.

    Any input will be appreciated!

    V

    I think that's what you want.

    var doc, secondTable, secondTableTextCotainers = [], ps, firstFrame, lastFrame, nextFrame;
    doc = app.properties.activeDocument;
    if (!doc) {
        alert("Jerk");
        exit();
    };
    app.findTextPreferences = null;
    app.findTextPreferences.findWhat = "\x16";
    var tables = doc.findText(false);
    if (tables.length > 1) secondTable = tables[1];
    else exit();
    lastFrame = secondTable.parent.insertionPoints[secondTable.index + 1].parentTextFrames[0];
    firstFrame = secondTable.parentTextFrames[0];
    secondTableTextCotainers.push(firstFrame);
    if (lastFrame != firstFrame) {
        nextFrame = firstFrame;
        while (nextFrame = nextFrame.nextTextFrame) {
            secondTableTextCotainers.push(nextFrame);
            if (nextFrame == lastFrame) break;
        }
    }
    var l = secondTableTextCotainers.length;
    // You might want to change this line
    while (l--) secondTableTextCotainers[l].fillColor = "Yellow";
    
  • Why the second table does not show?

    <? XML version = "1.0" encoding = "utf-8"? >
    " < = xmlns:mx mx:Application ' http://www.Adobe.com/2006/MXML "
    xmlns: Data = "" com.kg.Data. * ""
    Width = '100% '.
    Height = "100%".
    Initialize = "getParameterNumbers ()" "
    backgroundColor = "#FFFFFF" >

    < mx:Script >
    <! [CDATA]
    Import mx.rpc.events.FaultEvent;
    Import mx.rpc.events.ResultEvent;
    Import mx.collections.ArrayCollection;
    Import mx.charts.PieChart;
    Import mx.charts.series.PieSeries;
    Import mx.charts.Legend;
    import com.kg.data.ParameterCount;

    [Bindable]
    public var paramCount:ArrayCollection;

    Gets the initial set of data from the server
    private function getParameterNumbers (): void {}
    remoteObject.getParameterCount ();
    addSecondChart();
    }

    Manage the received message.
    private void resultHandler(event:ResultEvent):void {}
    paramCount = new ArrayCollection();
    var parameterResultData:ArrayCollection = ArrayCollection (event.result);
    var resultLength:Number = parameterResultData.length;
    for (var i: Number = 0; i < resultLength; i ++) {}
    var tempParamResult:ParameterCount = new ParameterCount();
    tempParamResult.name = parameterResultData.getItemAt (i) .name;
    tempParamResult.count = parameterResultData.getItemAt (i) .count;
    paramCount.addItem (tempParamResult);
    }
    }

    Manage a message error.
    private void faultHandler(event:FaultEvent):void {}
    statusTextArea.text += "received fault:"+ event.fault + '\n'; '.
    }


    public function addSecondChart (): void {}
    var chart: PieChart;
    var series: PieSeries.

    series = new PieSeries();
    series.nameField = "name";
    Series.Field = "count";
    Series.filters = [];

    table = new PieChart();
    chart.percentWidth = 100;
    chart.percentHeight = 100;
    chart.showDataTips = true;
    chart.dataProvider = paramCount;
    Chart.Series = [series];

    P1. AddChild (Chart);
    }

    []] >
    < / mx:Script >

    < mx:RemoteObject id = "remoteObject".
    destination = "pokerDataSource".
    result = "resultHandler (Event); »
    Fault = "FaultHandler (Event); "/ >


    < mx:HBox width = "100%" id = "topHBox" >
    < mx:VBox >
    < mx:PieChart id = "firstChart".
    dataProvider = "{paramCount}.
    showDataTips = "true".
    selectionMode = "unique."
    itemRollOverColor = "#FF0066" >
    < mx:series >
    < mx:PieSeries

    field = 'count '.
    field name = 'name '.
    labelPosition = "legend."
    / >
    < / mx:series >
    < / mx:PieChart >
    < mx:Legend dataProvider = "{firstChart}" / >
    < / mx:VBox >

    < mx:TextArea id = "statusTextArea".
    Width = '100% '.
    Height = "100%".
    backgroundAlpha = "0".
    focusAlpha = '0 '.
    Selectable = "false" / >
    < / mx:HBox >
    < mx:Panel id = "p1" / >
    < / mx:Application >

    Hi kavehg,

    I just wonder if you try to add the second table too early? You have

    Initialize = "getParameterNumbers ()" in your statement of app, then "

    getParameterNumbers (): void

    {
    remoteObject.getParameterCount ();
    addSecondChart();

    }

    Have you tried either

    (a) you put getParameterNumbers creationComplete rather initialize?

    (b) addSecondChart running on another manager of altogether, for example just put a button temporarily and run it on the click event.

    Maybe wrong, but just seems to me that the call may be all advance what p1 may have added chlildren?

    Richard

  • Add records in the target table

    Hi all
    I HAV done an interface for a simple source data transfer to the target. When I run it, the records are stored in the target table. Now, I want to launch the interface (for the same or different source table) and add the records to existing records in the target table.

    Kindly guide me, explaining how shud I do the addition in the target table.

    Thanks in advance.

    Hello

    You can use the IKM control add... it will add records...

    Thank you.

  • constraint - maximum one record has the status "active" in a table.

    Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - Prod
    PL/SQL Release 10.2.0.5.0 - Production
    CORE Production 10.2.0.5.0
    AMT for Linux: Version 10.2.0.5.0 - Production
    NLSRTL Version 10.2.0.5.0 - Production

    I thank in advance. I have a table like this:


    CREATE THE TABLE FIFAPPS. FS_MST_SUPPLIER
    (
    SUPL_CODE VARCHAR2 (12-BYTE) NOT NULL,
    SUPL_STATUS VARCHAR2 (12 BYTES) BY DEFAULT 'ACTIVE' NOT NULL
    )

    How the constraint such that no more than a supl_code supl_status = 'ACTIVE' table.

    For example:

    -BELOW IS NOT CORRECT BECAUSE THERE ARE TWO RECORDS WITH SUPL_STATUS = 'ACTIVE '.
    sheet 1: (supl_code = '1', SUPL_STATUS = 'ACTIVE')
    sheet 2: (supl_code = '2', SUPL_STATUS = 'NON ACTIVE')
    record 3: (supl_code = '3', SUPL_STATUS = 'ACTIVE')

    -BELOW IS CORRECT BECAUSE IT IS THERE ONLY ONE RECORD WITH SUPL_STATUS = 'ACTIVE '.
    sheet 1: (supl_code = '1', SUPL_STATUS = 'ACTIVE')
    sheet 2: (supl_code = '2', SUPL_STATUS = 'NON ACTIVE')
    record 3: (supl_code = '3', SUPL_STATUS = 'NON ACTIVE')

    -BELOW IS CORRECT BECAUSE IT IS THERE HAS A RECORD WITH SUPL_STATUS = 'ACTIVE '.
    sheet 1: (supl_code = '1', SUPL_STATUS = 'NON ACTIVE')
    sheet 2: (supl_code = '2', SUPL_STATUS = 'NON ACTIVE')
    record 3: (supl_code = '3', SUPL_STATUS = 'NON ACTIVE')

    Hello

    Don't know what you're trying to achieve, but here's a way not to have a single file with the status "ACTIVE".

    CREATE TABLE FS_MST_SUPPLIER
    (
    SUPL_CODE VARCHAR2(12 BYTE) NOT NULL,
    SUPL_STATUS VARCHAR2(12 BYTE) DEFAULT 'ACTIVE' NOT NULL
    )
    
    insert into fs_mst_supplier VALUES(1,'ACTIVE');
    insert into fs_mst_supplier VALUES(2,'INACTIVE');
    insert into fs_mst_supplier VALUES(3,'INACTIVE');
    
    create unique index idx_fs on FS_MST_SUPPLIER(case when supl_status ='ACTIVE' then 'ACTIVE' else null end);
    
    insert into FS_MST_SUPPLIER values(4,'ACTIVE'); -- this would fail
    
  • Help with the query to select only one record from the result set in double

    Hello

    Please help with the query. Version of Oracle database we use is 10g R2.

    I have a vision that is duplicated IDS, but they are used across the different functions. See below examples of data. Please help me with a query to select only one record (based on ID regardless of the area) from the bottom of the result set of duplicate records. For what is the point of view is there unique records, given the combination of the fields ID, Org, DF, dry, Sub-Sec

    ID
    Org
    DF
    Sec Sub-Sec

    (163)CQCPDMCPDMHD(163)PCENGENGENG(163)CQASICASICIS8888TSTACTACTAC(163)TSHEHESW6789CQINFOINFOFOS6789PCSECSYSSECSYSINFO16789TSSECSYSSECSYSINFO29009PCBMSBMSBMS1

    My result set must eliminate the duplicate identifiers regardless of whoever we choose of the result set. (I mean without distinction Org, DF, s, Sub-s). My expected result set should be.

    ID
    DSB

    DF
    SEC
    Sub-Sec
    (163)CQCPDMCPDMHD8888TSTACTACTAC6789CQINFOINFOFOS9009PCBMSBMSBMS1


    Thank you

    Orton

    Hello

    This sounds like a job for ROW_NUMBER:

    WITH got_r_num AS

    (

    SELECT id, DSB, df, s, sub_sec org

    ROW_NUMBER () OVER (PARTITION BY ID.

    ORDER BY org

    ) AS r_num

    OF view_x

    )

    SELECT id, DSB, df, sub_sec s,

    OF got_r_num

    WHERE r_num = 1

    ;

    He is a Top - N query example, where you choose the elements of N (N = 1 in this case) from the top of an ordered list.

    I hope that answers your question.
    If not, post a small example of data (CREATE TABLE and INSERT, only relevant columns instructions) to your sample data and the results desired from these data.  (I know that you said that you were a view selection.  Just for this thread, pretending it is a picture and post simple CREATE TABLE and INSERT statements to simulate your point of view).
    Point where the above query is to produce erroneous results, and explain, using specific examples, how you get the right results from data provided in these places.  (I didn't quite understand the explanation above.  I don't know why you want to

    ID ORG DF DRY SUB_SEC

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

    1234 CQ DPRK DPRK HD

    and is not

    1234 IS CQ ASIC, ASIC

    or

    TS 1234 IT IT SW

    or

    1234 CQ ASIC ASIC HD

    )
    If you change the query at all, post your modified version.
    Always say what version of Oracle you are using (for example, 11.2.0.2.0).

    See the FAQ forum: https://forums.oracle.com/message/9362002

  • SQL - select Help - box When? Return value of the second Table?

    -Next to people on this forum I am probably somewhere between a beginner and an intermediate SQL user.

    Ive been using a case when stated in plsql to find "all who has status in any program was canceled during a specific time, but have become or are still active in another program"

    So, Im actually trying to return a value from another table in a case where, but this isn't anthing taste other than a text declared as 'Yes' or 'no '.

    This is the select statement - y at - it another way to do it where I can get the results I need?

    -case when pp.party_id in (select pp1.party_id - cancelled active clients in another program)

    of asa.program_participation pp1,.

    ASA.curr_prog_participation_status cpps1

    where pp1.program_participation_id = cpps1.program_participation_id

    and pp1.party_id = pp.party_id

    and cpps1.code_value = 'Act')

    So 'Yes' is still 'No' end as Active_in_Other_Prg

    So - instead of 'Yes', I want essentially the program they are active or pp1.program_id, another null

    It is possible that the client can be active in more than one program as well.

    Any help is greatly appreciated, I explored with if and decodes but I can't get anything to work.

    Ben

    Looks like an outer join. See doc ora: joins at

    Select p

    q.party_id

    q.program_id

    of table_with_party_id p

    , (select pp1.party_id - cancelled active clients in another program)

    pp1.program_id

    of asa.program_participation pp1,.

    ASA.curr_prog_participation_status cpps1

    where pp1.program_participation_id = cpps1.program_participation_id

    and pp1.party_id = pp.party_id

    and cpps1.code_value = 'ACT') q

    where p.party_id = q.party_id (+)

    Note: In the example above shoudn't it be a space between the (and +), but the forum software automatically converts to

    The outer join will connect display all records in the table p and q records only if fits the party_id, IE q.party_id and q.program_id will be null if there is no match.

    Edit: adding program_id

  • finding duplicate records in the DB table, or the data trasnpose

    Hello

    I have a question...

    Key | UID. Start Dt | End date. / / DESC


    --------------------------------------------------------------------------------
    1. 101 | March 12 09 | 30 May 09 | UID101

    2. 101 | January 1 09 | February 25 09 | UID101

    3. 102. 13 March 09 | 30 March 09 | UID102

    4. 103. 13 March 09 | 30 March 09 | UID103

    5. 103. 13 March 09 | April 1 09 | UID103

    6. 104. 13 March 09 | 30 May 09 | UID104

    7. 104. February 25 09 | 29 May 09 | UID104

    8. 105. 15 February 09 | March 1 09 | UID105

    9. 105. April 1 09 | 30 May 09 | UID105

    The query must know UID in duplicate according to the above data, which are stored in the same form in a table. The definition of the UID duplicate is

    (1) UID repeating themselves (records by 2) ex are 101,103,104 and 105.
    (2) each UID has two dates and date of end of beginning.
    (3) the UID for which dates are overlaping. For ex: touch #4, 103 UID whose start dates are March 13 09-30-Mar-09 and there also another record, with the # 5 UID 103 key dates are 13 Mar 09 to 1 April 09. Here, there is overlap or intersection in line #4 with key #5 key dates dates of rank. This UID is duplicated UID by def.

    What precedes that falls under def and selectable are 103 and 104 only 102 UID has only a single line, UID 105 dates are mutually exclusive or not that overlap and even for the UID.

    Is there a function available DB to make use of?


    Wanted not to delete records or duplicate records.

    There is a report to display these duplicate records.

    It would be good for me if I can get the data transposed for UID

    as

    Of

    4. 103. 13 March 09 | 30 March 09 | UID103

    5. 103. 13 March 09 | April 1 09 | UID103

    TO
    UID. Start the t1d. End t1d. Start the T2D. End T2D
    103: |13-Mar-09|30-Mar-091-Apr-09 13 March 09

    Any advice or ideas can be useful to gr8

    Thank you...

    It can also be done without Analytics:

    WITH test_data AS (
      SELECT  1 AS KEY, 101 AS UD, TO_DATE('03/12/2009','MM/DD/YYYY') AS START_DT, TO_DATE('05/30/2009','MM/DD/YYYY') AS END_DT, 'UD101' AS DSC FROM DUAL UNION ALL
      SELECT  2 AS KEY, 101 AS UD, TO_DATE('01/01/2009','MM/DD/YYYY') AS START_DT, TO_DATE('02/25/2009','MM/DD/YYYY') AS END_DT, 'UD101' AS DSC FROM DUAL UNION ALL
      SELECT  3 AS KEY, 102 AS UD, TO_DATE('03/13/2009','MM/DD/YYYY') AS START_DT, TO_DATE('03/30/2009','MM/DD/YYYY') AS END_DT, 'UD102' AS DSC FROM DUAL UNION ALL
      SELECT  4 AS KEY, 103 AS UD, TO_DATE('03/13/2009','MM/DD/YYYY') AS START_DT, TO_DATE('03/30/2009','MM/DD/YYYY') AS END_DT, 'UD103' AS DSC FROM DUAL UNION ALL
      SELECT  5 AS KEY, 103 AS UD, TO_DATE('03/13/2009','MM/DD/YYYY') AS START_DT, TO_DATE('04/01/2009','MM/DD/YYYY') AS END_DT, 'UD103' AS DSC FROM DUAL UNION ALL
      SELECT  6 AS KEY, 104 AS UD, TO_DATE('03/13/2009','MM/DD/YYYY') AS START_DT, TO_DATE('05/30/2009','MM/DD/YYYY') AS END_DT, 'UD104' AS DSC FROM DUAL UNION ALL
      SELECT  7 AS KEY, 104 AS UD, TO_DATE('02/25/2009','MM/DD/YYYY') AS START_DT, TO_DATE('05/29/2009','MM/DD/YYYY') AS END_DT, 'UD104' AS DSC FROM DUAL UNION ALL
      SELECT  8 AS KEY, 105 AS UD, TO_DATE('02/15/2009','MM/DD/YYYY') AS START_DT, TO_DATE('03/01/2009','MM/DD/YYYY') AS END_DT, 'UD105' AS DSC FROM DUAL UNION ALL
      SELECT  9 AS KEY, 105 AS UD, TO_DATE('04/01/2009','MM/DD/YYYY') AS START_DT, TO_DATE('05/30/2009','MM/DD/YYYY') AS END_DT, 'UD105' AS DSC FROM DUAL
    )
    select  t1.ud,
         t1.key, t1.start_dt, t1.end_dt,
         t2.key, t2.start_dt, t2.end_dt
    from     test_data t1
    ,     test_data t2
    where     t1.ud = t2.ud
      and     t1.key < t2.key
      and     ((t1.end_dt - t1.start_dt) + (t2.end_dt - t2.start_dt)) >
            (greatest(t1.end_dt, t2.end_dt) - least(t1.start_dt, t2.start_dt))
    /
    

    Result:

            UD        KEY START_DT   END_DT            KEY START_DT   END_DT
    ---------- ---------- ---------- ---------- ---------- ---------- ----------
           103          4 13-03-2009 30-03-2009          5 13-03-2009 01-04-2009
           104          6 13-03-2009 30-05-2009          7 25-02-2009 29-05-2009
    

    In addition, you will need to adjust the date a little comparison, depending on whether you set two periods where the first End_date is equal to the start_date in the second, because duplication or not.

    Published by: tijmen on December 21, 2009 06:17

  • Findout incompatibility records between the two tables.

    I need help on findout the unmatched records between two different tables.

    Each table has a + 42Crores Records.

    The type of data (Char) are the same for the two tables but datalength is different between a table and the table B.

    Indexes are created on the two tables on the required fields

    There is no Geom data exists on the two tables.



    For example:

    A Table: =.
    Number of records + 42Crores
    Rating: TOLD char (20)

    Table B: =.
    Number of records + 42Crores
    Field: TOLD Char (16)

    I took individual accounts, there are number of difference is 3868 only, with respect to the count (*) selection.

    I ran the query "Select TOLD OF A LESS SELECT TOLD OF B", but I don't have the answer.

    Please let me know how to solve the problem.

    The variable length char shouldn't be a problem...
    You just need to ensure that the first table has more lines than the second, if the problem persists You ' l I hide it, and then use a column alias...

    Let know us...

  • Win 7 pro license on 2 devices if one desktop and the second a mobile?

    Hello

    I have read, it is possible to install a win 7 pro license on 2 devices if one is a desktop computer and the second mobile (Tablet, netbook or laptop).
    Is this true?
    If yes how to do it please?
    I bought a laptop with win 7 pro on this subject and we must now install it on a new desktop computer that I am editing.
    THX

    This is not true.

    No, the key that can be used with 32-bit or 64-bit Windows 7 is exclusively for use with the disc 1. You cannot use install both. 1 license, 1 installation, so choose wisely. If you want to install Windows 7 32 or 64 bit on another partition or another computer, you must purchase an additional license.

    http://www.Microsoft.com/Windows/buy/default.aspx

    http://Windows.Microsoft.com/en-us/Windows7/get-a-new-Windows-product-key

    INSTALLATION AND USE RIGHTS.

    a. one copy per computer. You can install one copy of the software on a single computer. This computer is "licensed computer.

    b. a computer license. You can use the software on up to two processors of the computer under license at some point. Except as provided in these license terms, you cannot use the software on any other computer.

    c. number of users. Except as provided in these license terms, only one user may use the software at a time.

    d. other Versions. The software may include several versions, such as 32-bit and 64-bit. You may install and use only one version at a time.

  • Records in the Child Table to return DBAT connector deletion and addition

    I'm trying to add a record of the child to a resource DBAT (11.1.1.5). The structure of the Table is set up like this:

    OIM_USR

    Usr_key First name Last_name

    OIM_ROLE

    USR_KEY ROLE_KEY

    Where OIM_USR is the parent, and OIM_ROLE is the child that can store multiple values per user.  The problem arises when there is already an existing value in the child table. Consider the following example for instance

    OIM_USR

    Usr_key First name Last_name
    45JohnDOE

    OIM_ROLE

    USR_KEY ROLE_KEY
    452454
    454453

    If I add another line to the role of the identity UI table Edit tab added resource role, but IOM is remove the previous two lines and then adding them back. We know that it is because the source OIM_ROLE table contains a timestamp of creation triggered update time when a row is added. If I add a line to OIM_ROW then all three are getting updates for a reason any. We can also see the history of resource shows three updates. Inserting a record of the child should not call the process of update tasks. I've attached a screenshot of the history of the resource.

    In addition, I upped the DBAT Connector logs and he showed a trace of remove:

    DELETE FROM OIM_ROLES WHERE OIM_ROLES. USR_KEY =?

    Why he deletes all children lines before an insertion?

    I think you use OOTB DBAT connector without modification. I think that's how its design to add/change/delete files. For child process also updated form, we follow the same approach.

    Are you facing any functional problem in connector DBAT to reach your use cases?

    ~ J

  • What is the preferred means of data transmission as a type of record between the nested table of pl/sql program or an associative array

    What is the preferred means of data transmission in the associative array of the nested table record vs

    Choose between Nested Tables and associative arrays

    The two nested tables and associative arrays (formerly index - by tables) use similar index notation, but they have different characteristics when it comes to persistence and ease of passing parameters.

    Nested tables can be stored in a column of data, but can of associative arrays. Nested tables can simplify the SQL operations where you would normally join a single-column table with a larger table.

    Associative arrays are appropriate for relatively small lookup tables where the collection can be constructed in memory whenever a procedure is called or a package is initialized. They are good for the collection of the information volume is unknown beforehand, because there is no fixed limit on their size. Their index values are more flexible, as associative array indices can be negative, can be no sequential and can use values of string instead of numbers.

    PL/SQL automatically converts between the bays of the host and the associative arrays that use values of digital keys. The most effective way to move the collections to and from the database server is to implement data values in associative arrays, and then use these associative arrays with erections in bulk (the FORALL statement or BULK COLLECT clause).

    With the help of documents and Collections of PL/SQL

    Read this:

    How to pass the record set as a parameter of the procedure.

    https://community.Oracle.com/thread/2375173?TSTART=0

Maybe you are looking for