match Word between two table

Hello

I want to retrieve those records where full word of the 'text' column does not match with the word in the column 'object' of another table.

for example

for id 101 table abc, it contains the Word as "Air Blow" which is exactly with 101 id of table of bcd. I don't want the case

With abc as

(

Select 101 as id, "Air Blow" as double union text

Select 102, 'Air' Union double

Select 103, 'Sink' double union

Select 104, 'Air press' Union double

Select 105, 'Putting out fires' double

),

BCD as

(

Select 101 as id, "Air blown near the mount" as subject, 'WE' as a double union countries

Select 102, "Air breath seen here," 'China' of the double union

Select 103, 'Throughput', 'canada' to double union

Select 104, 'air pressure', 'UK' Union double

Select 105, 'Fire engine', 'Ubdy' from dual

)

Select * from abc, bcd

where abc.id = bcd.id

and upper (abc.text) <>(bcd.subject) upper

OUTPUT

IDTEXTID_1ObjectCOUNTRY
102Air blown102Blowing air sawChina
103Water flow103Water flowCanada
105Putting out fires105FirefighterUbdy

Another corresponding original solution post results...

SQL > ed
A written file afiedt.buf

1 with abc as)
2. Select 101 as id, "Air BLOW" as double union text
3. Select 102, 'Air' Union double
4. Select 103, 'Sink' double union
5. Select 104, 'Air press' Union double
6 select 105, 'Fire extinguish' from dual
7    ),
8 bcd as
9    (
10. Select 101 as id, "Air blown near the mount" as subject, 'WE' as a double union countries
11. Select 102, "Air breath seen here," 'China' of the double union
12. Select 103, 'Throughput', 'canada' to double union
13. Select 104, 'air pressure', 'UK' Union double
14 select 105, 'Fire engine', 'Ubdy' from dual
15)
16. Select *.
17 ABC join bcd on (abc.id = bcd.id)
18 * where no regexp_like (bcd.subject, abc.text, 'i')
SQL > /.
TEXT ID COUNTR OBJECT ID
---------- --------------- ---------- ----------------------- ------
102 air blowing here view China 102
103 103 water flow flow of water canada
Fire 105 105 fire Ubdy

3 selected lines.

Tags: Database

Similar Questions

  • I got a prob while creating a link/link between two tables in a jdeveloper11g

    Hi guys...

    I got a prob while creating a link/link between two tables in a jdeveloper11g, help me.

    I use two table employee, Department.

    Unfortunately there is no primary key and foreign key in these tables.now i updated on those of table structure.

    I want to create a form like it should be a link between the Department data, i.e. data and employee while the Department is changed then only present corresponding employees in this block...

    Table structure as follows

    Employee:

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

    employe_id,

    name,

    Department,

    GR,

    Date of birth

    Department of justice

    Department:

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

    department_id,

    department_name;

    Note: in the employee department table is the same as in the department table department_id...

    So, you want to build master / detail between Department & sub_departments?

    In the same way, create a new, yet another link between departments & sub_departments, so that the connection is:

    Department.Department_Id = sub_departments.department_id

  • I need to implement Drag N Drop between two tables that saves the two records

    I need to implement Drag N Drop between two tables that saves the two records on a third page, using drag 'n drop.

    Check out this video http://baigsorcl.blogspot.com/2011/01/drag-and-drop-collection-in-oracle-adf.html

  • two relationships between two tables

    Hi all

    I created a cube in my db (using OWB) of two relationships to my time dimension. A relationship shows the start time of a process, that the other represents the date of termination or end.

    example of the cube:

    Fact1
    Fact2
    Dim_Time1
    Dim_Time2

    where Dim_time1 and Dim_Time2 link to the same dimension.

    Unfortunately I have trouble this manually import in obiee administrator. I imported the fact table and the dimension of the physical layer table. Can I move to the business layer and create the two joins between two tables. But the overall consistency check up a mistake, I shouldn't have two relationships between two tables and remove a foreign key.

    What I am doing wrong?

    Kind regards

    Knut

    Knut,

    In your example, you should have a time dimension in the phyiscal layer and alias of this 2 x, for Dim_time1 and for Dim_time2, in this way aliases are separate tables as the BI server point of view and you define releations separate on the same table, you can define specific to each alias dim relevant time joins.

    In this way, you will have two time decreases intensity in MDB layer also, has 'Dim-Start Time' and a ' Sun - term time "or similar.

    Hope this helps,
    Alastair

  • Use a where clause clause if there is a relationship between two tables

    Is it possible to use a where clause clause if there is a relationship between two tables.
    I have a relationship between two tables:
    And a.customer = b.customer (+)

    If b.customer exists in a.customer I would add this in where clause
    And b.info = 'X '.
    But how?

    It's the outer joins by chance?

    If so, why not just:

    and  b.customer(+) = a.customer
    and  b.info(+) = 'X'
    

    BTW, I put the two "b" on the left column to make it easier to read. Some people mix that makes me crazy, but makes no difference to the query.

  • How to remove the extra space between two Table HTML

    Hello

    I wrote a code for printing costs. But there is more space between two Table Html, how I can remove it.

    Please run that Code

    Start

    HTP.p (')
    < html >
    (< body > ');

    HTP.p (')
    < TABLE align = "left" width = "500" cellspacing = "0" cellpadding = "0" border = "1" >
    < tr > < td align = 'right' white-space: nowrap; > Ph-2201751 < table >
    < td > < table >
    < /tr >
    < tr > < td align = "center" white-space: nowrap; > < B > < table > < /B > SATYAM MODERN PUBLIC SCHOOL
    < td > < table >
    < /tr >
    < b >
    < td align = "center" white-space: nowrap; > < i > < H3 > (AFFILIATED to THE CBSC, NEW DELHI CODE No. 53544) < / H3 > < /I > < table >
    < td > < table >
    < /tr >
    < tr > < td align = "center" white-space: nowrap; > new colony Braham, - 131001 (h) < table >
    < td > < table >
    < /tr >
    < tr > < td align = "center" white-space: nowrap; > RECEPTION COSTS < table >
    < td > < table >
    < /tr >
    < /table >
    < TABLE width = "500" cellspacing = "0" cellpadding = "0" border = "1" >
    < b >
    < td width = "100" white-space: nowrap; > receipt no.: < table >
    < td width = "100" white-space: nowrap; > Date received: < table >
    < /tr >
    < b >
    < td width = "100" white-space: nowrap; > name: < table >
    < td width = "100" white-space: nowrap; > father name: < table >
    < /tr >
    < b >
    < td width = "100" white-space: nowrap; > class & s: < table >
    < td width = "100" white-space: nowrap; > A/C No. : < table >
    < /tr >
    < b >
    < td width = "100" white-space: nowrap; > from: < table >
    < td width = "100" white-space: nowrap; > to: < table >
    < /tr >

    (< /table > ');
    HTP.p (')
    < / body >
    (< / html > ');
    end;


    Thank you

    Ed

    Hello

    HTML is valid, that your code print?

    
    

    Wouldn't be as below?

    
    

    BR, Jari

    Published by: jarola on December 18, 2009 15:22
    I test your code
    http://Apex.Oracle.com/pls/OTN/f?p=40323:25
    I can't see any extra space between the tables

  • getting data between two tables

    Hi everyone, I need help with a query that seems simple, but I can't understand. consider the following data.

    with data as (

    s élire 802 cd from dual union all

    select 803 cd from dual union all

    select 804 cd from dual

    data2 as

    ( select 804 cd from dual )


    I want to join the two tables so that the result will be as follows:

    in the above data, we can see that 804 is common in both tables.  in this case, the output should be 804.

    Similarly, if 2 data include the following:

    data2 as

    ( select 804 cd from dual union all

    Select 803 cd from dual

    )


    the output is then 803 804.



    Now consider the following data

    with data as (

    s élire 802 cd from dual union all

    select 803 cd from dual union all

    select 804 cd from dual

    )

    take data2 table is empty


    I want to join the two tables, and in this case, the output should be 802,803,804.  data2 table is empty, then the default behavior is to get all the data in the data table. Since there is no line that corresponds to rows in the data table,

    the default behavior is to display output all data in the data table.  in this case 802,803,804

    can someone write a query for this?

    Hello

    elmasduro wrote:

    Hi Frank, thanks for the request.  These are very good questions. Here are the answers

    What happens if data2 rows, but none of them match data CD?

    It won't happen because the integrity of the data.

    ...

    I see it; a data line 2 will be in the data.  You have a FOREIGN KEY constraint, or something similar, so if cd = 804 exists in database2, then it must also exist in the data.

    What happens if the data is empty and data2 is not?

    If data is empty and data2 is not, then the data2 data should be released.

    for example

    with the data as)

    data table is empty

    data2 as

    (select cd 804 Union double all the)

    Select cd 805 double

    )

    When you join data and data2 account with the above data, then the output should be 804 805.  data2 data should be the display if the data table is empty. ...

    Doesn't that contradict what you said earlier?  Previously, it seemed to say that each row of data2 will be in the data, but now you give an example where all data2 lines are not in the data.

    If the first is true, then the solution in response #2 should work.

    If the latter is true, you can change the query like this:

    WITH got_r_num AS

    (

    SELECT NVL (d.cd, d2.cd) AS cd

    DENSE_RANK () (ORDER IN CASE

    WHEN d.cd IS NOT NULL

    AND d2.cd IS NOT NULL

    THEN "A".

    WHEN d.cd IS NOT NULL

    THEN 'B '.

    ANOTHER 'C '.

    END

    ) AS r_num

    DATA d

    FULL OUTER JOIN data2 d2 ON d.cd = d2.cd

    )

    SELECT cd

    OF got_r_num

    WHERE r_num = 1

    ORDER BY cd

    ;

  • Comparison between two tables

    Hello

    I have two tables USERS and LISTS:

    And I want that there is a comparison between these two tables executed when user table USERS connect to the application.

    They must compare the columns between the SEXES and AGE and if some users have the same attributes in its ranks as in a line in the table LISTS (here is unique each line) so that the user gets in his line in the column 'LIST_ID' the ID of the line with which attributes between GENDER and AGE.

    Example:

    USERS TABLE: exampleuser | Boby | McGrahem | Male | 18. -------

    LISTS OF TABLE: 28 | examplelist | Male | 18

    Once the Login of the user Boby gets in its ranks the ID = 28 because the SEX and AGE corresponds to the row of table LIST:

    Result:

    USERS TABLE: exampleuser | Boby | McGrahem | Male | 18. 28

    
    CREATE TABLE  "USERS" 
       (    "USERNAME" VARCHAR2(15) NOT NULL ENABLE, 
            "FORRNAME" VARCHAR2(15) NOT NULL ENABLE,                  
            "SURNAME" VARCHAR2(15) NOT NULL ENABLE, 
            "GENDER" VARCHAR2(10) NOT NULL ENABLE,   
            "AGE" NUMBER, 
            "LIST_ID" NUMBER, 
             CONSTRAINT " USERS_PK" PRIMARY KEY ("USERNAME")
      USING INDEX  ENABLE
    
    

    CREATE TABLE  "LISTS" 
       (    " LIST_ID" NUMBER NOT NULL ENABLE, 
            " LISTNAME" VARCHAR2(50) NOT NULL ENABLE, 
            "GENDER" VARCHAR2(10) NOT NULL ENABLE, 
            "AGE" VARCHAR2(3) NOT NULL ENABLE,  
             CONSTRAINT " LISTS_PK" PRIMARY KEY ("LIST_ID")
      USING INDEX  ENABLE
       
    

    I need help for coding this, if someone be so good.

    This is my essay:


    DECLARE  
        v_listid varchar2(100);   
        BEGIN  
          
        SELECT  LIST_ID into v_listgid
         FROM LISTS
         WHERE GENDER = (SELECT GENDER
                              FROM USERS 
                            WHERE UPPER(TRIM(USERNAME)) = UPPER(TRIM(:APP_USER)))
         AND AGE = (SELECT AGE
                              FROM USERS  
                            WHERE UPPER(TRIM(USERNAME)) = UPPER(TRIM(:APP_USER)));
    
         UPDATE USERS   
        SET LIST_ID =  v_listid   WHERE UPPER(TRIM(USERNAME)) = UPPER(TRIM(:APP_USER));  
      
        END;
    

    I'd like to REALLY shy away using the USER name as the primary key, because the fact that users can create duplicate user names... YOU should NEVER base a PK on the entry of user, the better to let the database create and maintain this element of date...

    FIX:

    UPDATE to users U

    SET List_Id = (SELECT List_Id OF lists L WHERE L.Gender = U.Gender and L.SOMENUMBER = U.SOMENUMBER) AND

    Upper (U.UserName) = UPPER(:APP_USER);

    Don't really want to cut the strings, Oracle which will do since they are of type varchar2 columns...

    Thank you

    Tony Miller
    Software LuvMuffin
    Ruckersville, WILL

  • How to match columns from two tables with

    Hello:
    I have two tables as below:

    Table1::(Base Table)
    Country | Prefix | Prefix_Length
    Travel | 001 | 3
    CountryB. 0012 | 4
    PaysC | 00443 | 5
    CountryD | 0091 | 4

    :(Detail Table) table2
    The population | Area | Prefix
    500 | AreaA | 0015921
    1000 | AreaB | 00122
    400. AreaC. 00443743
    300. ALIS | 0091333
    100. AreaA | 001

    I need to match these two tables with prefix columns (whose length is not fixed in the two tables: but it starts with 00 in the two tables). Two different countries the prefix may be similar up to a certain length. Thus, Prefix_Length can be used to determine (exactly) how much time should be taken in the search of Table2.

    Output:
    Country | Prefix | Area | Population
    Travel | 001 | AreaA | 600
    CountryB. 0012 | AreaB | 1000
    PaysC | 00443 | AreaC. 400
    CountryD | 0091 | ALIS | 300

    Please help me with your valuable comments.

    -Tender

    Try this

    with base_table as (
                        select 'CountryA' country,'001' prefix,3 prefix_length from dual union all
                        select 'CountryB','0012',4 from dual union all
                        select 'CountryC','00443',5 from dual union all
                        select 'CountryD','0091',4 from dual
                       ),
       detail_table as (
                        select 10 no_of_call,'0015921' prefix from dual union all
                        select 3,'00122' from dual union all
                        select 50,'00443743' from dual union all
                      select 50,'00443643' from dual union all
                        select 300,'0091333' from dual union all
                        select 60,'001' from dual
                       ) 
    
    SELECT  country,
            prefix,sum(no_of_call)
       FROM (
             select  country,
            b.prefix,no_of_call,
            decode(no_of_call,lead(no_of_call,1,0) over(partition by no_of_call order by b.prefix,no_of_call),'y','n') y_or_no
      from  base_table b,
            detail_table d
      where b.prefix = substr(d.prefix,1,prefix_length))
      where y_or_no !='y'
      group by  country,
            prefix
      order by country,
            prefix;
    

    Published by: Vi on 20 February 2012 01:07

  • The most elegant way to get the difference between two tables - not least!

    Hello


    Simplified example of what I'm trying to achieve - I have two tables ORIGINAL and REVISED.


    My aim is to compare the two, such as; -


    When there is data in the two tables I get the difference between the Budget column, and if there is no difference, so I don't want no lines.

    When data exists in the ORIGINAL, but not in review, I want to the inverse of the current value of the Budget column.

    Where the data exist in REVISED I want the REVISED value.

    I can see how I can do this, see below, but is there a more elegant solution?




    Data for the ORIGINAL table
    select '801040' entity, '2186' expense_type, 234000 budget
    from dual
    union all
    select '801040' entity, '3001' expense_type, 1000 budget
    from dual
    union all
    select '801040' entity, 'P132' expense_type, 34000 budget
    from dual
    union all
    select '801040' entity, 'P135' expense_type, 43000 budget
    from dual
    Data for the REVISED table
    select '801040' entity, '2186' expense_type, 235000 budget
    from dual
    union all
    select '801040' entity, 'P132' expense_type, 34000 budget
    from dual
    union all
    select '801040' entity, 'P139' expense_type, 56000 budget
    from dual
    Desired output



    ENTITY EXPENSE_TYPE DIFFERENCE
    ------ ------------ ----------
    801040 2186 1000
    801040 3001-1000
    801040 P135-43000
    801040 P139 56000

    5 selected lines.



    Code current to achieve this, is there a better way?
    select original.entity
    ,      original.expense_type
    ,       (nvl(revised.budget,0) - original.budget) as difference
    from   original
    ,      revised
    where  original.entity = revised.entity(+)
    and    original.expense_type = revised.expense_type(+)
    and   (nvl(revised.budget,0) - original.budget) != 0
    union all
    select  revised.entity
    ,       revised.expense_type
    ,       revised.budget as difference
    from   revised
    where  not exists
    (select 'x'
    from   original
    where  original.entity = revised.entity
    and    original.expense_type = revised.expense_type)
    and    revised.budget != 0
    Thanks a lot for your comments,.


    Robert.

    Published by: Robert Angel on January 17, 2012 03:31 to change is not equal to! = - Thanks for the heads up
    SQL> with original
      2  as
      3  (
      4    select '801040' entity, '2186' expense_type, 234000 budget
      5    from dual
      6    union all
      7    select '801040' entity, '3001' expense_type, 1000 budget
      8    from dual
      9    union all
     10    select '801040' entity, 'P132' expense_type, 34000 budget
     11    from dual
     12    union all
     13    select '801040' entity, 'P135' expense_type, 43000 budget
     14    from dual
     15  )
     16  , revised
     17  as
     18  (
     19    select '801040' entity, '2186' expense_type, 235000 budget
     20    from dual
     21    union all
     22    select '801040' entity, 'P132' expense_type, 34000 budget
     23    from dual
     24    union all
     25    select '801040' entity, 'P139' expense_type, 56000 budget
     26    from dual
     27  )
     28  select *
     29    from (
     30          select nvl(o.entity, r.entity) entity,
     31                 nvl(o.expense_type, r.expense_type) expense_type,
     32                 nvl(r.budget,0) - nvl(o.budget,0) budget
     33            from original o
     34            full join revised r
     35              on o.entity = r.entity
     36             and o.expense_type = r.expense_type
     37         )
     38   where budget <> 0
     39  /
    
    ENTITY EXPE     BUDGET
    ------ ---- ----------
    801040 2186       1000
    801040 P135     -43000
    801040 3001      -1000
    801040 P139      56000
    
    SQL>
    
  • Difference between two tables (ORA-01722)

    I am trying to get the difference of two tables on two databases.

    Walker I run the script below, it gives me a result that is not accurate.
    Select name, creation_time of v$datafile@REMOTE_database.com
    2 LESS THAN
    3 select name, creation_time from v$ datafile;

    I get 14 ranks of foregoing.
    However, when I run this script, I get an accurate count of the difference. How can I list the exact number instead of only to count the difference? Want lists all five name missing on table 2.
    SQL > SELECT a.cnt - b.cnt
    > count 2 (name) select cnt (of v$datafile@REMOTE_database.com) a, b
    3 (select count (name) NTC v$ datafile);

    A.CNT - B. CNT
    -----------
    5
    edited by: Albert Zaza on July 19, 2010 11:19

    have you tried:

    select trim(upper(name)) from v$datafile@REMOTE_database.com
     MINUS
     select trim(upper(name)) from v$datafile;
    
  • Matching records between 2 tables with duplicate records

    Hi all

    I need help in what follows.

    I have 2 tables Received_bills and Send_bills.

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

    -The DOF for Table SEND_BILLS

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

    CREATE TABLE SEND_BILLS

    (DATE OF "DATUM",

    NUMBER OF "PAYMENT."

    'CODE' VARCHAR2 (5 BYTE)

    )  ;

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

    -The DOF for Table RECEIVED_BILLS

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

    CREATE TABLE 'RECEIVED_BILLS '.

    (DATE OF "DATUM",

    NUMBER OF "PAYMENT."

    'CODE' VARCHAR2 (5 BYTE),

    VARCHAR2 (5 BYTE) 'STATUS' )  ;

    INSERTION of REM in RECEIVED_BILLS

    TOGETHER TO DEFINE

    Insert. RECEIVED_BILLS (DATUM, PAYMENT, CODE, STATE) values (to_date('10-OCT-15','DD-MON-RR'), 19, 'A1', 'SUCCESS');

    Insert into RECEIVED_BILLS (PAYMENT, CODE, DATE, STATUS) values (to_date('10-OCT-15','DD-MON-RR'), 'A5', 'SUCCESS', 25);

    Insert into RECEIVED_BILLS (PAYMENT, CODE, DATE, STATUS) values (to_date('10-OCT-15','DD-MON-RR'), 47, 'A4', 'FAILED');

    Insert into RECEIVED_BILLS (PAYMENT, CODE, DATE, STATUS) values (to_date('10-OCT-15','DD-MON-RR'), 19, 'A1', 'FAILED');

    Insert into RECEIVED_BILLS (PAYMENT, CODE, DATE, STATUS) values (to_date('10-OCT-15','DD-MON-RR'), 19, 'A1', 'SUCCESS');

    INSERTION of REM in SEND_BILLS

    TOGETHER TO DEFINE

    Insert into SEND_BILLS (DATUM, CODE) values (to_date('10-OCT-15','DD-MON-RR'), 19, 'A1');

    Insert into SEND_BILLS (DATUM, CODE) values (to_date('10-OCT-15','DD-MON-RR'), 19, 'A1');

    Insert into SEND_BILLS (DATUM, CODE) values (to_date('10-OCT-15','DD-MON-RR'), 19, 'A1');

    Insert into SEND_BILLS (DATUM, CODE) values (to_date('10-OCT-15','DD-MON-RR'), 25, 'A5');

    Insert into SEND_BILLS (DATUM, CODE) values (to_date('10-OCT-15','DD-MON-RR'), 47, 'A4');

    Insert into SEND_BILLS (DATUM, CODE) values (to_date('09-OCT-15','DD-MON-RR'), 19, 'A8');

    Insert into SEND_BILLS (DATUM, CODE) values (to_date('10-OCT-15','DD-MON-RR'), 20, 'A1');

    Insert into SEND_BILLS (DATUM, CODE) values (to_date('10-OCT-15','DD-MON-RR'), 19, 'A1');

    Insert into SEND_BILLS (DATUM, CODE) values (to_date('10-OCT-15','DD-MON-RR'), 25, 'A5');

    Insert into SEND_BILLS (DATUM, CODE) values (to_date('10-OCT-15','DD-MON-RR'), 25, 'A5');

    I match all records of send_bills and received_bills with a status of 'SUCCESS' There is no single column in the table.

    Correspondence held payment of columns, the code and the scratch cards, but it may also duplicate records. But even if there are duplicates, I also need those records in the query results

    the query I wrote is this:

    SELECT SEND.*

    REC received_bills, send_bills send

    WHERE send.datum = rec.datum

    AND send.payment = rec.payment

    AND send.code = rec.code

    AND 'rec.status =' SUCCESS

    ;

    The query results give me this

    OCTOBER 10, 1519A1
    OCTOBER 10, 1519A1
    OCTOBER 10, 1519A1
    OCTOBER 10, 1519A1
    OCTOBER 10, 1519A1
    OCTOBER 10, 1519A1
    OCTOBER 10, 1525A5
    OCTOBER 10, 1519A1
    OCTOBER 10, 1519A1
    OCTOBER 10, 1525A5

    The result of the correct application would be

    OCTOBER 10, 1519A1
    OCTOBER 10, 1525A5
    OCTOBER 10, 1519A1

    The select statement that I need I want to use a loop to insert records in another table.

    Can someone help me please?

    Thanks in advance.

    Best regards

    Caroline

    Hi, Caroline.

    Caroline wrote:

    Hi all

    I need help in what follows.

    I have 2 tables Received_bills and Send_bills.

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

    -The DOF for Table SEND_BILLS

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

    CREATE TABLE SEND_BILLS

    (DATE OF "DATUM",

    NUMBER OF "PAYMENT."

    'CODE' VARCHAR2 (5 BYTE)

    )  ;

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

    -The DOF for Table RECEIVED_BILLS

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

    CREATE TABLE 'RECEIVED_BILLS '.

    (DATE OF "DATUM",

    NUMBER OF "PAYMENT."

    'CODE' VARCHAR2 (5 BYTE),

    VARCHAR2 (5 BYTE) 'STATUS');

    INSERTION of REM in RECEIVED_BILLS

    TOGETHER TO DEFINE

    Insert. RECEIVED_BILLS (DATUM, PAYMENT, CODE, STATE) values (to_date('10-OCT-15','DD-MON-RR'), 19, 'A1', 'SUCCESS');

    Insert into RECEIVED_BILLS (PAYMENT, CODE, DATE, STATUS) values (to_date('10-OCT-15','DD-MON-RR'), 'A5', 'SUCCESS', 25);

    Insert into RECEIVED_BILLS (PAYMENT, CODE, DATE, STATUS) values (to_date('10-OCT-15','DD-MON-RR'), 47, 'A4', 'FAILED');

    Insert into RECEIVED_BILLS (PAYMENT, CODE, DATE, STATUS) values (to_date('10-OCT-15','DD-MON-RR'), 19, 'A1', 'FAILED');

    Insert into RECEIVED_BILLS (PAYMENT, CODE, DATE, STATUS) values (to_date('10-OCT-15','DD-MON-RR'), 19, 'A1', 'SUCCESS');

    INSERTION of REM in SEND_BILLS

    TOGETHER TO DEFINE

    Insert into SEND_BILLS (DATUM, CODE) values (to_date('10-OCT-15','DD-MON-RR'), 19, 'A1');

    Insert into SEND_BILLS (DATUM, CODE) values (to_date('10-OCT-15','DD-MON-RR'), 19, 'A1');

    Insert into SEND_BILLS (DATUM, CODE) values (to_date('10-OCT-15','DD-MON-RR'), 19, 'A1');

    Insert into SEND_BILLS (DATUM, CODE) values (to_date('10-OCT-15','DD-MON-RR'), 25, 'A5');

    Insert into SEND_BILLS (DATUM, CODE) values (to_date('10-OCT-15','DD-MON-RR'), 47, 'A4');

    Insert into SEND_BILLS (DATUM, CODE) values (to_date('09-OCT-15','DD-MON-RR'), 19, 'A8');

    Insert into SEND_BILLS (DATUM, CODE) values (to_date('10-OCT-15','DD-MON-RR'), 20, 'A1');

    Insert into SEND_BILLS (DATUM, CODE) values (to_date('10-OCT-15','DD-MON-RR'), 19, 'A1');

    Insert into SEND_BILLS (DATUM, CODE) values (to_date('10-OCT-15','DD-MON-RR'), 25, 'A5');

    Insert into SEND_BILLS (DATUM, CODE) values (to_date('10-OCT-15','DD-MON-RR'), 25, 'A5');

    I match all records of send_bills and received_bills with a status of 'SUCCESS' There is no single column in the table.

    Correspondence held payment of columns, the code and the scratch cards, but it may also duplicate records. But even if there are duplicates, I also need those records in the query results

    the query I wrote is this:

    SELECT SEND.*

    REC received_bills, send_bills send

    WHERE send.datum = rec.datum

    AND send.payment = rec.payment

    AND send.code = rec.code

    AND 'rec.status =' SUCCESS

    ;

    The query results give me this

    OCTOBER 10, 15 19 A1
    OCTOBER 10, 15 19 A1
    OCTOBER 10, 15 19 A1
    OCTOBER 10, 15 19 A1
    OCTOBER 10, 15 19 A1
    OCTOBER 10, 15 19 A1
    OCTOBER 10, 15 25 A5
    OCTOBER 10, 15 19 A1
    OCTOBER 10, 15 19 A1
    OCTOBER 10, 15 25 A5

    The result of the correct application would be

    OCTOBER 10, 15 19 A1
    OCTOBER 10, 15 25 A5
    OCTOBER 10, 15 19 A1

    The select statement that I need I want to use a loop to insert records in another table.

    Can someone help me please?

    Thanks in advance.

    Best regards

    Caroline

    Want to get answers that work?  Then make sure that the CREATE TABLE and INSERT statements you post too much work.  Test (and, if necessary, correct) your statements before committing.  You have a stray "." in the first INSERT statement for received_bills and receikved_bills.status is defined as VARCHAR2 (5), but all values are 6 characters long.

    There are 5 lines in send_bills that are similar to the

    10 OCTOBER 2015 19 A1

    Why do you want that 2 rows like this in the output, not 1 or 3, or 4 or 5?  Is it because there are 2 matching rows in received_bills?  If so, you can do something like this:

    WITH rec AS

    (

    SELECT the reference, payment, code

    , ROW_NUMBER () OVER (PARTITION BY datum, payment, code)

    ORDER BY NULL

    ) AS r_num

    OF received_bills

    Situation WHERE = 'SUCCESS'

    )

    send AS

    (

    SELECT the reference, payment, code

    , ROW_NUMBER () OVER (PARTITION BY datum, payment, code)

    ORDER BY NULL

    ) AS r_num

    OF send_bills

    )

    SELECT send.datum, send.payment, send.code

    REC, send

    WHERE send.datum = rec.datum

    AND send.payment = rec.payment

    AND send.code = rec.code

    AND send.r_num = rec.r_num

    ;

    Note that the main request is very similar to the query you posted, but the last condition has changed.

    If you need to insert these lines in another table, you can use this query in an INSERT statement. There is no need of a loop, or for any PL/SQL.

  • Left join between two tables using two different conditions

    I have following three tables with their data, as shown below.

    CREATE TABLE TIREMASTERPROCESS_TEMP
    (
    PRODUCTIONCODE TANK (12 BYTES),
    FIELDNAME CHAR (12 BYTES),
    DATACHR VARCHAR2 (60 BYTE),
    REVISIONNO TANK (3 BYTES),
    DATANUM NUMBER (9.4)
    )
    Whether the table c. and its sample data are like

    FIELDNAME DATACHR REVISIONNO DATANUM PRODUCTIONCODE
    AB No. Nch 1 100 0
    AB No. Nch 1 108 0
    AB No.-of-Nch 1 1 0
    Ass42 teased dishes 1 0
    Ass42 BTDrumNo1 BTD-051 1 0
    AB53 BTDrumNo1 BTD-051 104 0


    CREATE TABLE materialcode
    (
    UPPERMATERIALCODE CHAR (20),
    PROCESSNO TANK (3),
    PROCESSADOPTDATE TANK (9)

    )
    Whether the table b. and its sample data are like

    UPPERMATERIALCODE PROCESSNO PROCESSADOPTDATE
    Ass42 1 20120717
    AB53 108 20121121
    111 20111104 AS05
    104 20120928 AS30


    CREATE TABLE BUILDINGSCHEDULEMASTER
    (
    BUILDINGSIZE TANK (5 BYTES),
    GTCODE FLOAT (4 BYTES),
    TIREPERCART NUMBER (3.0).
    BUILDINGLOT NUMBER (3.0)
    )
    Whether table and its sample data are like

    BUILDINGSIZE GTCODE TIREPERCART BUILDINGLOT
    AB42A 4 12 ass42
    AB53A 4 88 AB53
    AS30A AS30 4 80
    BF03A 1 90 BF03


    Now, I need to get some data in these fields by using the suite of mappings.

    « PR_ » || Trim (a.BUILDINGSIZE) | ' / MPL2' Processid,--PRIMARY KEY
    TO_DATE (substr (NVL(b.PROCESSADOPTDATE,'19800101'), 7, 2) |) » /'|| SUBSTR (NVL(b.PROCESSADOPTDATE,'19800101'), 5, 2) | » /'|| SUBSTR (NVL(b.PROCESSADOPTDATE,'19800101'), 1, 4). (' 01:00:00 ',' dd-mm-yyyy hh24:mi:ss') starteff, to_date (SUBSTR (NVL(b.PROCESSADOPTDATE,'19800101'), 7, 2) |) » /'|| SUBSTR (NVL(b.PROCESSADOPTDATE,'19800101'), 5, 2) | » /'|| SUBSTR (NVL(b.PROCESSADOPTDATE,'19800101'), 1, 4). (' 01:00:00 ',' dd-mm-yyyy hh24:mi:ss') startDate.
    b.PROCESSNO revisioncodeid,
    a.BUILDINGLOT tirepercart ,
    CASE WHEN c.FIELDNAME = 'BTDrumNo1' then c.DATACHR end drumtype1.
    BOX WHEN (trim (C.DATACHR) = '1' and trim (C.FIELDNAME) = "No. Nch") and THEN click 'YES '.
    ANOTHER 'NO '.
    END may-BUG,
    case
    When c.FIELDNAME = 'Wavy'
    AND c.DATACHR = 'Use' THEN on 'YES '.
    When c.FIELDNAME = 'Wavy'
    AND c.DATACHR <>'Use' THEN 'NO '.
    fine wavy


    Now for the tables A and B I have the simple join as condition

    a.GTCODE = b.UPPERMATERIALCODE

    But I have to use two different left join conditions to join the table B and C to calculate the RESP fields according to the condition.
    Now, I have to use

    (trim (b.UPPERMATERIALCODE)). » -'|| Trim (b.PROCESSNO) = Trim (c.PRODUCTIONCODE) | » -'|| Trim (c.REVISIONNO)

    condition to get the data for the WAVY and DRUMTYPE1 fields.

    But at the same time, I have to use

    substr (Trim (b.UPPERMATERIALCODE), 1, 2). » -'|| Trim (b.PROCESSNO) = Trim (c.PRODUCTIONCODE) | » -'|| Trim (c.REVISIONNO)

    conition to derive the CHAFER field.

    And for this reason I am come so many duplicates and do not correct results for JUNEBUG, WAVY, DRUMTYPE1, and STARTDATE field.

    I need some advice as how can I do so that I get the correct results without duplicates for the PRIMARY KEY.

    Thank you

    Mahesh

    It would have been easier to answer if you gave us your example query that gives incorrect results - which both show us what you are doing and give us a starting point.
    Insert instructions for data, rather than only the data would have helped too, making it more quick to test this point.
    You do not show what you have done with your two outer join criteria, but I think you need to list TIREMASTERPROCESS_TEMP in your query twice, with alias names. Here's what I did:

    select a.BUILDINGSIZE, a.GTCODE, b.PROCESSNO ,  c1.FIELDNAME, c1.DATACHR, C2.FIELDNAME, C2.DATACHR
    , CASE WHEN c1.FIELDNAME='BTDrumNo1' then c1.DATACHR end drumtype1
    , CASE WHEN (trim(c2.DATACHR) = '1' and trim(c2.FIELDNAME) = 'No-of-Nch') THEN 'YES' ELSE 'NO' END CHAFER
    , case when c1.FIELDNAME='Wavy' AND c1.DATACHR='Use' THEN 'YES'
           when c1.FIELDNAME='Wavy' then 'NO' else null end wavy
    from BUILDINGSCHEDULEMASTER        A
    join materialcode b on a.GTCODE=b.UPPERMATERIALCODE
    left outer join TIREMASTERPROCESS_TEMP c1
       ON trim(b.UPPERMATERIALCODE)||'-'||trim(b.PROCESSNO) = trim(c1.PRODUCTIONCODE)||'-'||trim(c1.REVISIONNO)
    left outer join TIREMASTERPROCESS_TEMP c2
       ON substr(trim(b.UPPERMATERIALCODE),1,2)||'-'||trim(b.PROCESSNO) = trim(c2.PRODUCTIONCODE)||'-'||trim(c2.REVISIONNO)
    

    C1 is an alias for the TIREMASTERPROCESS_TEMP line which is necessary for drumtype1 and wavy, c2 is an alias for the TIREMASTERPROCESS_TEMP line required for JuneBug. There was some minor errors in your calculations of field I tried to correct.

    The results are:

    BUILD GTCO PRO FIELDNAME    DATACHR    FIELDNAME    DATACHR    DRUMTYPE1  CHA WAV
    ----- ---- --- ------------ ---------- ------------ ---------- ---------- --- ---
    AB53A AB53 108                         No-of-Nch    1                     YES
    AB42A AB42 1   BTDrumNo1    BTD-051    No-of-Nch    1          BTD-051    YES
    AB42A AB42 1   Wavy         NotUse     No-of-Nch    1                     YES NO
    AS30A AS30 104                                                            NO
    

    Hope this helps,
    David

  • connect before between two tables

    I have this table structure

    I have what it takes to return the value on prior connection

    create table OBJECT_LIST
    (
      cal_objid   NUMBER(4) not null,
      obj_name    VARCHAR2(100),
      obj_type    VARCHAR2(20),
      obj_title   VARCHAR2(20),
      description VARCHAR2(50)
    );
    alter table OBJECT_LIST
      add constraint OBJECT_LIST_PK primary key (CAL_OBJID);
      
      
      create table CAL_ERD
    (
      obj_child    NUMBER(5) not null,
      obj_parent   NUMBER(5) not null,
      obj_rel_type VARCHAR2(50)
    );
    alter table CAL_ERD
      add constraint CAL_ERD_PK primary key (OBJ_CHILD, OBJ_PARENT);
        
      alter table CAL_erd
      add constraint cal_parent_FK foreign key (obj_parent)
      references object_list (CAL_objid);
      
      
       alter table CAL_erd
      add constraint cal_child_FK foreign key (obj_child)
      references object_list (cal_objid);
     
     
    insert into object_list (cal_objid,
                                 obj_name,
                                 obj_type)
                              values(1192,
                                    'MainObject',
                                    'Form');
                                    
                                    
                 insert into object_list (cal_objid,
                                 obj_name,
                                 obj_type)
                              values(1193,
                                    'SecondObject',
                                    'Form');  
                                    
                                    
                 insert into object_list (cal_objid,
                                 obj_name,
                                 obj_type)
                              values(1194,
                                    'ThirdObject',
                                    'Form');    
                                    
                                    
                  insert into object_list (cal_objid,
                                 obj_name,
                                 obj_type)
                              values(1195,
                                    'FourthObject',
                                    'Form');  
                                    
                                    
        insert into object_list (cal_objid,
                                 obj_name,
                                 obj_type)
                          values(1196,
                                 'FirthObject',
                                 'Form');
                                 
                             
                                 
                                 
                                  insert into cal_erd values(1193,1192,null);
                                  insert into cal_erd values(1194,1193,null);
                                  insert into cal_erd values(1195,1194,null);
    
     
     

    in the first table values

    CAL_OBJID OBJ_NAME, OBJ_TYPE OBJ_TITLE DESCRIPTION
    1192 MainObject form
    1193 SecondObject form
    1194 ThirdObject form
    1195 FourthObject form
    1196 FirthObject form

    the second value of the table
    OBJ_CHILD OBJ_PARENT OBJ_REL_TYPE
    1192 1193
    1194 1193
    1195 1194

    SQL script that I am trying

    WITH t AS 
        (SELECT li.obj_name,
                li.obj_type,
                li.obj_title,
                li.DESCRIPTION, 
                LEVEL AS lvl,
                SYS_CONNECT_BY_PATH(li.obj_name, '/')paths 
        FROM object_list li,cal_erd er
         where li.cal_objid = er.obj_parent(+)
             START WITH obj_parent IS NULL
             CONNECT BY
                      NOCYCLE PRIOR obj_child = obj_parent)
      SELECT obj_name,
             LEAD(obj_name) OVER(ORDER BY paths) AS child_name,
             obj_type ,
             obj_title ,
             DESCRIPTION ,
             substr(paths,
                           INSTR(paths, '/', 1, CASE WHEN lvl > 1 THEN lvl-1 END) + 1 , 
                           INSTR(paths, '/', 1, CASE WHEN lvl > 1 THEN lvl END)                    
                          - INSTR(paths, '/', 1, CASE WHEN lvl > 1 THEN lvl-1 END) - 1 ) AS parent_name
        FROM t;
     


    get value

    OBJ_NAME, OBJ_TYPE OBJ_TITLE DESCRIPTION PARENT_NAME CHILD_NAME
    FirthObject FourthObject form
    FourthObject form

    I what like to be like that

    OBJ_NAME, OBJ_TYPE DESCRIPTION OBJ_PARENT OBJ_TITLE OBJ_CHILD

    SecondObject MainObject form

    ThirdObject SecondObject form MainObject

    fourthObject ThirdObject shape SecondObject

    I would like if possible show the id of ojb_name

    Hello

    Here's a way to achieve the expected results, you want to:

    WITH t AS
        (SELECT obj_parent
              , li.obj_name
              , li.obj_type
              , li.obj_title
              , li.DESCRIPTION
              , LEVEL AS lvl
              , SYS_CONNECT_BY_PATH(li.obj_name, '/')paths
        FROM object_list li
             LEFT JOIN cal_erd er ON (li.cal_objid = er.obj_child)
             START WITH obj_parent IS NULL
             CONNECT BY
                      NOCYCLE PRIOR cal_objid = obj_parent),
    t2 AS (
      SELECT LEAD(obj_name) OVER(PARTITION BY substr(paths, 1
                                                          , CASE WHEN INSTR(paths, '/', 1, 2)> 0
                                                                 THEN INSTR(paths, '/', 1, 2)-1
                                                                 ELSE LENGTH(paths)
                                                            END)
                                     ORDER BY paths) AS child_name
           , obj_name
           , obj_type
           , obj_title
           , DESCRIPTION
           , substr(paths,
                           INSTR(paths, '/', 1, CASE WHEN lvl > 1 THEN lvl-1 END) + 1 ,
                           INSTR(paths, '/', 1, CASE WHEN lvl > 1 THEN lvl END)
                          - INSTR(paths, '/', 1, CASE WHEN lvl > 1 THEN lvl-1 END) - 1 ) AS parent_name
        FROM t)
    SELECT *
      FROM t2
     WHERE child_name IS NOT NULL;
    

    Result:

    CHILD_NAME OBJ_NAME, OBJ_TYPE OBJ_TITLE PARENT_NAME DESCRIPTION

    SecondObject MainObject form

    ThirdObject SecondObject form MainObject

    FourthObject ThirdObject shape SecondObject

    Kind regards

    Steve

  • Several foreign key joins between two tables

    Hello

    I have a question about the creation of a repository.

    I have a date and a fact dimension. The fact table has about 10 columns in foreign key to the date Dimension.

    In this case I should create 10 aliases to create joins in the physical layer and MDB or y at - it another way to handle this situation.

    I ask this question because 10 aliases can get very confusing for me at the later stage of time when creating reports.

    With the help of OBIEE 10.1.3

    If you want to see in the industry as
    End date, start date, date etc. nearby
    you need to create 10 aliases for this purpose in the physical layer, make them drag in MDB and model, and then drag to the area of topic

    Score pls correct/good

Maybe you are looking for