How to join two tables of different schemas of Oracle by using a subquery

I'm trying to join two different schemas of Oracle tables using a subquery. I can extract data from each of the tables without problem. However, when I combine select statements it by using a subquery I get Oracle error *'ORA-00936: lack of expression ' *. Given that each SELECT statement runs on its own without error I don't understand what's missing. I'm trying to get the result set is matching the LINE_ID of PDTABLE_12_1 in the schema with the table PDTABLE_201 MAT_DESCRIPTION DD_12809 in the RA_12809 schema.

The query is as follows:

SQL = "SELECT [DD_12809]. [PDTABLE_12_1]. LINE_ID OF [DD_12809]. [PDTABLE_12_1] JOIN "_".
+ "(SELECT [RA_12809]. [PDTABLE_201]. MAT_DESCRIPTION "_".
"FROM [RA_12809]. [PDTABLE_201]) AS FAB "_".
+ 'ON [DD_12809]. [PDTABLE_12_1]. PIPING_MATER_CLASS = FAB. PIPING_MATER_CLASS ".

The format of the request is copied from a manual of programming SQL.

I also tried running the query uses a right JOIN on the two tables, but got the same results. Any ideas would be useful. Thank you!

Published by: user11338343 on October 19, 2009 06:55

The format for the join of two tables in Oracle feels like any other database:

SELECT a.col1, a.col2, ..., b.col1, b.col2, ...
FROM   schema1.table1 a,
       JOIN schema2.table2 b ON a.col = b.col and ...
WHERE  a.other_col = 'FRED'
AND    ....;

Do not place bracketed identifiers in Oracle. The account that connects to the database must have select privileges on the two tables.

Tags: Database

Similar Questions

  • How to join two tables if you transpose the rows, columns and rows in one of the table

    Hi guys,.

    can someone help me please in the write request

    I have two tables

    Agents and Agent phones but in the agent phones table for the id of an agent it displays 4 rows because one of the column there types of different phones (office, mobile, home, fax)

    So instead of display 4 rows, I used max(case...) to convert rows to columns

    now how to reach it with another table

    Requirement:

    Database: 11.2.0.2.0

    create the table AGENT_PHONE

    (

    agent_id NUMBER (20) not null,

    agent_type_code VARCHAR2 (10) not null,

    agent_type_prefix VARCHAR2 (10) not null,

    Phone_Number VARCHAR2 (16) not null,

    phone_type_code VARCHAR2 (10) not null

    )

    CREATE TABLEAGENTS

    (

    agent_id NUMBER (20) not null,

    agent_type_code VARCHAR2 (10) not null,

    agent_type_prefix VARCHAR2 (10) not null,

    NAME VARCHAR2 (40) NOT NULL

    )

    INSERT INTO AGENT_PHONE(AGENT_ID,AGENT_TYPE_CODE,AGENT_TYPE_PREFIX,PHONE_NUMBER,PHONE_TYPE_CODE)

    VALUES (29709, ARE ', 'OFFICE', '4805551436', 'CELL');

    INSERT INTO AGENT_PHONE(AGENT_ID,AGENT_TYPE_CODE,AGENT_TYPE_PREFIX,PHONE_NUMBER,PHONE_TYPE_CODE)

    VALUES (29709, ARE ', 'OFFICE', '1111111111', 'PHONE');

    INSERT INTO AGENT_PHONE(AGENT_ID,AGENT_TYPE_CODE,AGENT_TYPE_PREFIX,PHONE_NUMBER,PHONE_TYPE_CODE)

    VALUES (29709, ARE ', 'OFFICE', '2223334444',' OFF');

    INSERT INTO AGENT_PHONE(AGENT_ID,AGENT_TYPE_CODE,AGENT_TYPE_PREFIX,PHONE_NUMBER,PHONE_TYPE_CODE)

    VALUES (29709, ARE ', 'OFFICE', '5556667788', 'FAX');

    INSERT INTO VALUES AGENTS

    (29709, ARE ', 'OFFICE', 'FLY');

    INSERT INTO VALUES AGENTS

    (1234, ARE ', 'OFFICE', 'MIKE');

    SELECT * FROM AGENT_PHONES

    AGENT_IDAGENT_TYPE_CODEAGENT_TYPE_PREFIXPHONE_NUMBERPHONE_TYPE_CODE

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

    29709REOFFICE4805551436CELL
    29709REOFFICE1111111111PHONE
    29709REOFFICE2223334444OFF
    29709REOFFICE5556667788

    FAX

    SELECT * AGENTS

    AGENT_IDAGENT_TYPE_CODEAGENT_TYPE_PREFIX

    NAME

    29709REOFFICEROB
    1234REOFFICE

    MIKE

    This is so the data we have in both table

    Now, I transposed rows to columns in the table of agent phones so I used the following query

    SELECT AP. AGENT_ID,. AGENT_TYPE_CODE,. AGENT_TYPE_PREFIX.

    MAX (CASE WHEN AP. PHONE_TYPE_CODE = 'CELL' THEN AP. PHONE_NUMBER END) AS CELL.

    MAX (CASE WHEN AP. PHONE_TYPE_CODE = 'OFF' THEN AP PHONE_NUMBER END) AS TURNED OFF.

    MAX (CASE WHEN AP. PHONE_TYPE_CODE = 'FAX' THEN AP. PHONE_NUMBER END) LIKE FAX,.

    MAX (CASE WHEN PHONE_TYPE_CODE = 'PHONE'. THEN AP PHONE_NUMBER END) AS PHONE

    AGENT_PHONE AP

    WHERE AP. AGENT_ID = 29709

    GROUP OF AP. AGENT_ID, AP. AGENT_TYPE_CODE, AP. AGENT_TYPE_PREFIX.

    AGENT_IDAGENT_TYPE_CODEAGENT_TYPE_PREFIXCELLOFFFAXPHONE
    129709REOFFICE4805551436222333444455566677881111111111

    My question is how this to join the agents table so that my output should be like this...

    I want to display all the results in the table of the Agent, even if they are not in the table of agent phones. As you can see there are other agent id 1234 is also populated

    AGENT_IDAGENT_TYPE_CODEAGENT_TYPE_PREFIXNAMEAGENT_IDAGENT_TYPE_CODEAGENT_TYPE_PREFIXCELLPHONEOFFFAX

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

    29709REOFFICEROB29709REOFFICE4805551436111111111122233344445556667788
    1234REOFFICEMIKE

    Currently, I run this query and I get the output as below

    SELECT *.

    AGENTS HAS

    LEFT OUTER JOIN AGENT_PHONE AP

    ON A.AGENT_ID = AP. AGENT_ID

    AND A.AGENT_TYPE_CODE = AGENT_TYPE_CODE.

    AND A.AGENT_TYPE_PREFIX = AGENT_TYPE_PREFIX.

    AGENT_IDAGENT_TYPE_CODEAGENT_TYPE_PREFIXNAMEAGENT_IDAGENT_TYPE_CODEAGENT_TYPE_PREFIXPHONE_NUMBERPHONE_TYPE_CODE
    129709REOFFICEROB29709REOFFICE4805551436CELL
    229709REOFFICEROB29709REOFFICE1111111111PHONE
    329709REOFFICEROB29709REOFFICE2223334444OFF
    429709REOFFICEROB29709REOFFICE5556667788FAX
    51234REOFFICEMIKE

    I want id 29709 agent in a line with 1234 agent also id to display

    You can rotate your phone number of agent in columns

    Select *.

    of AGENT_PHONE

    pivot)

    min (PHONE_NUMBER)

    for PHONE_TYPE_CODE in ('CELL' as a 'CELL', 'PHONE' like 'PHONE', 'OFF' in the 'OFF', 'FAX' as 'FAX')

    )

    AGENT_ID AGENT_TYPE_CODE AGENT_TYPE_PREFIX CELL PHONE OFF FAX
    29709 RE OFFICE 4805551436 1111111111 2223334444 5556667788

    Then you can join to view inline or CTE

    with AGENT_PHONE_PIVOT like)

    Select *.

    of AGENT_PHONE

    pivot)

    min (PHONE_NUMBER)

    for PHONE_TYPE_CODE in ('CELL' as a 'CELL', 'PHONE' like 'PHONE', 'OFF' in the 'OFF', 'FAX' as 'FAX')

    )

    )

    SELECT *.

    AGENTS HAS

    LEFT OUTER JOIN AGENT_PHONE_PIVOT AP

    ON A.AGENT_ID = AP. AGENT_ID

    AND A.AGENT_TYPE_CODE = AGENT_TYPE_CODE.

    AND A.AGENT_TYPE_PREFIX = AGENT_TYPE_PREFIX.

    AGENT_ID AGENT_TYPE_CODE AGENT_TYPE_PREFIX NAME AGENT_ID AGENT_TYPE_CODE AGENT_TYPE_PREFIX CELL PHONE OFF FAX
    29709 RE OFFICE ROB 29709 RE OFFICE 4805551436 1111111111 2223334444 5556667788
    1234 RE OFFICE MIKE - - - - - - -

    Is that what you're looking for?

  • How to join two tables to retrieve the data from the columns in table two. Tables have primary and foreign key relationships

    Hello

    I want to join the two tables to retrieve the data from the columns of the two table passing parameters to the join query. Tables have primary and foreign key relationships

    Details of the table

    Alert-1 - AlertCode (FK), AlerID (PK)

    2 AlertCode-AlertDefinition-(PK)

    Help, please


    ----------

    Hi Vincent,.

    I think that you have not worked on adf 12.1.3.  In adf 12.1.3 you don't have to explicitly create the association. When you create the EO to your table, Association xxxxFkAssoc, will be created by ADF12.1.3 for you automatically. Please try this and do not answer anything... You can also follow the links below. I solved the problem by using the following link

    Oracle ADF Guide step by step - Oracle ADF tutorial: creating a relationship of the master / detail using Oracle ADF

    ---

  • How to join two tables without constraints?

    I want to get back the tables to join without constraints!

    Table 1:

    get 100
    101 wet
    series 102

    and

    Table 2:

    10 xxx movies
    11 yyy
    12 zzz
    QUERY 1:

    SELECT * FROM TO LEAVE P, CUSTES C
    WHERE (P.ID, P.NAME, C.ID, C.NAME) IN (SELECT P1.ID, P1.NAME, C1.ID, C1.NAME
    OF P1, C1 CUSTES TO GO)

    I got the result like this,

    ID ID NAME
    101 wet 10 xxx
    zzz 101 wet 12
    YYY 101 wet 11
    Get 100 10 xxx
    102 the yyy 11 value
    series 102 10 xxx
    100 get 11 yyy
    100 get 12 zzz
    102 the value 12 zzz

    All ranks was sent three times! but I need to write once.

    QUERY 2:

    Select id as pid, name as the name of go
    Union
    Select id as pid, name as the name of custes;

    QUERY2 OUTPUT IS.

    NAME OF PID
    10 xxx movies
    11 yyy
    12 zzz
    get 100
    101 wet
    series 102

    In the 2nd query get the attached files of the two tables. But my need is two tables record to display like this

    ID NAME NAME_1 ID_1
    Get 10 xxx 100
    wet 11 101 yyy
    set of 12 zzz 102

    I'm looking for is, I want to join in parallel columns in my trips!

    Is there a source... ? or the same code is happy...!

    Something like that?

    WITH t1 AS (SELECT '100' id, 'get' name FROM DUAL
                UNION
                SELECT '101', 'wet' FROM DUAL
                UNION
                SELECT '102', 'set' FROM DUAL),
         t2 AS (SELECT '10' id, 'xxx' name FROM DUAL
                UNION
                SELECT '11', 'yyy' FROM DUAL
                UNION
                SELECT '12', 'zzz' FROM DUAL)
    SELECT id,
           name,
           (SELECT id
              FROM (SELECT ID, name, ROWNUM rw FROM t2) t_in
             WHERE t_in.rw = t_out.rw)
              id_1,
           (SELECT name
              FROM (SELECT ID, name, ROWNUM rw FROM t2) t_in
             WHERE t_in.rw = t_out.rw)
              name_1
      FROM (SELECT ID, name, ROWNUM rw FROM t1) t_out
    
    SQL> WITH t1 AS (SELECT '100' id, 'get' name FROM DUAL
      2              UNION
      3              SELECT '101', 'wet' FROM DUAL
      4              UNION
      5              SELECT '102', 'set' FROM DUAL),
      6       t2 AS (SELECT '10' id, 'xxx' name FROM DUAL
      7              UNION
      8              SELECT '11', 'yyy' FROM DUAL
      9              UNION
     10              SELECT '12', 'zzz' FROM DUAL)
     11  SELECT id,
     12         name,
     13         (SELECT id
     14            FROM (SELECT ID, name, ROWNUM rw FROM t2) t_in
     15           WHERE t_in.rw = t_out.rw)
     16            id_1,
     17         (SELECT name
     18            FROM (SELECT ID, name, ROWNUM rw FROM t2) t_in
     19           WHERE t_in.rw = t_out.rw)
     20            name_1
     21    FROM (SELECT ID, name, ROWNUM rw FROM t1) t_out;
    
    ID  NAME ID_1 NAME_1
    --- --- -- ---
    100 get 10 xxx
    101 wet 11 yyy
    102 set 12 zzz
    
    SQL>
    

    The number of rows in the tables are the same?

  • How to compare two TABLES and different lines of list?

    I have two structural equal paintings aaa and bbb
    that (could) have different lines.

    How can I compare the tables and display different lines?

    Peter

    Something like this->

    SELECT aaa.*,'bbb' "Not present in" FROM aaa
    MINUS
    SELECT bbb.*,'bbb' "Not present in" FROM bbb
    UNION ALL
    (
    SELECT bbb.*,'aaa' "Not present in" FROM bbb
    MINUS
    SELECT aaa.*,'aaa' "Not present in" FROM aaa
    )
    

    Kind regards.

    LOULOU.

  • Oracle how to multiply two columns of different tables and results

    Oracle how to multiply two columns of different tables and get the result in the third column?

    I want to multiply all the lines of the quantinty column in the table of quantity with the relevant lines of the table of prices price column and get the result of multiplying in the third column. What should I use procedure trigerr? OR IS IT POSSIBLE HOW TO DO IT PLEASE HELP :D

    Edited by: 994229 2013-03-15 12:44
    /* Formatted on 3/15/2013 3:51:08 PM (QP5 v5.185.11230.41888) */
    CREATE TABLE mytable1
    AS
       (SELECT 1 id, 5 VALUE FROM DUAL
        UNION ALL
        SELECT 2, 7 FROM DUAL
        UNION ALL
        SELECT 3, 8 FROM DUAL);
    
    CREATE TABLE mytable2
    AS
       (SELECT 1 id, 4 VALUE FROM DUAL
        UNION ALL
        SELECT 2, 12 FROM DUAL
        UNION ALL
        SELECT 10, 12 FROM DUAL);
    
      SELECT id,
             mytable1.VALUE,
             mytable2.VALUE,
             mytable1.VALUE * mytable2.VALUE product
        FROM mytable1 FULL OUTER JOIN mytable2 USING (id)
    ORDER BY id;
    
    ID     VALUE     VALUE_1     PRODUCT
    1     5     4     20
    2     7     12     84
    3     8
    10          12     
    
  • SQL: JOIN two table also corresponding column NULL how?

    Hello

    I'm trying to join two tables which works fine,
    But if there are NULL values, then, JOIN does not.
    I have two tables TEMP_DD AND TEMP_EE, in which two line
    is the column: allocation A_ID,.
    IE: 112 and NULL and I want both my sql output, but how?

    I tried under sql as it returns only a single line of 112 and does not return a null row which is a football game.


    SELECT * FROM TEMP_DD
    JOIN TEMP_EE
    ON (TEMP_DD.A_ID = TEMP_EE.A_ID);
    How to remedy this situation?

    create table TEMP_DD
    (
      A_ID VARCHAR2(3),
      B_ID VARCHAR2(4),
      C_ID VARCHAR2(10)
    );
    
    create table TEMP_EE
    (
      A_ID VARCHAR2(3),
      B_ID VARCHAR2(4),
      C_ID VARCHAR2(10)
    );
    
    insert into TEMP_DD (A_ID, B_ID, C_ID)
    values ('112', '1123', '12345678');
    insert into TEMP_DD (A_ID, B_ID, C_ID)
    values (NULL, '1123', '12345678');
    insert into TEMP_DD (A_ID, B_ID, C_ID)
    values ('212', '1123', '12345678');
    
    
    insert into TEMP_EE (A_ID, B_ID, C_ID)
    values ('112', '1123', '12345678');
    insert into TEMP_EE (A_ID, B_ID, C_ID)
    values (NULL, '1123', '12345678');
    insert into TEMP_EE (A_ID, B_ID, C_ID)
    values ('312', '1123', '12345678');
    OUTPUT
    ---------

    "112', ' 1123," "12345678".
    (NULL, ' 1123","12345678 ".

    Hello

    Wrap both sides in an NVL IE. NVL (col1, 'X'), WHERE = NVL(col2,'X').

    See you soon

    Ben

  • How to join two fields with slightly different data

    I have two columns, I need joined, both keep the columns of numeric data, but are of type varchar2 (6). The problem is that one of the columns keeps leading zeros to ensure that all 6 characters are used, but not the other. And columns preserve leading zeros may vary how many zeros are in the number-based computing.

    For example, the column with zeros can contain the number 4200, which would mean that he would remain with 2 zeros as 004200. Or it could contain 320, which means that he would remain with 3 zeros as 000320.

    The other column that does not have leading zeros not only keeps the number, so, in the example above, it would keep 4200 and 320 respectively.

    Can someone help on how to join these columns so that they match? I guess I have to delete the zeros in one or add zeros in the other? I tried to use the trunc with zeros on the ground, but it did not work...

    The following sql code:

    M06.mbr06_prv_id has no zeros, prv647.provider_id zeros. See bold below...

    SELECT
    M06.mbr06_prv_id,
    prv647.Site_ID
    Of
    Odw.mbr06_mbr_elig m06
    JOIN THE
    Odw.prv647_prov_exp prv647
    WE
    M06.mbr06_prv_id = prv647.provider_id
    WHERE
    M06.mbr06_subs_id = "999999999 '

    BTW, I have no control on how this data is represented in a table... !

    Hello

    user12296489 wrote:
    ... I guess I have to delete the zeros in one or add zeros in the other?

    Yes, this is how I see.
    LTRIM removes given characters from the beginning of a string. LPAD adds characters at the beginning of a string. I would use LTRIM in this case, because if you use LTRIM, you probably need to handle a single column. If you use LPAD, you have to play with the two columns, as one of them still has the extra 0, and it sometimes needs them.

    I tried to use the trunc with zeros on the ground, but it did not work...

    TRUNC is working on the kinds or DATEs; you have VARCHAR2s. You can convert them to numbers, but then you risk of errors to cause bad data (and it linked to the wrong data).
    >

    The following sql code:

    M06.mbr06_prv_id has no zeros, prv647.provider_id zeros. See bold below...

    SELECT
    M06.mbr06_prv_id,
    prv647.Site_ID
    Of
    Odw.mbr06_mbr_elig m06
    JOIN THE
    Odw.prv647_prov_exp prv647
    WE
    M06.mbr06_prv_id = prv647.provider_id
    WHERE
    M06.mbr06_subs_id = "999999999 '

    If you are certain that m06.mbr06_prv_id never has extra characters, whereas the join condition can be

    ON   m06.mbr06_prv_id   = LTRIM ( prv647.provider_id
                                      , '0'
                           )
    

    If this isn't the case, CUT then the two columns.

    BTW, I have no control on how this data is represented in a table... !

    Report a bad design is for people who don't have not this control. Numbers are the number of columns, not VARCHAR2. If the ID really needs to be strings, they should be validated and standardized once, when they are placed in the table, no more, and more, in all queries that use these columns.

    I hope that answers your question.
    If not, post a small example of data (CREATE TABLE and only relevant columns, INSERT statements) for all tables and also post the results desired from these data.
    Explain, using specific examples, how you get these results from these data.
    Always tell what version of Oracle you are using.

  • to join two columns with different data types

    Hello experts,

    I have two tables...
         create table1
       (
         col1 varchar2(20)
        );
        
      create table2
        (
          col1 number(10)
        );  
    
      
    with their data as below
              with table1 as
      (  select 'xx' col1 from dual union all 
         select 'yy' col1  from dual union all
         select '01' col1  from dual union all
         select '02' col1  from dual union all
         select '03' col1  from dual union all
         select '04' col1  from dual 
      ),table2 as 
       (
         select '01' col1 from dual union all
         select '02' col1 from dual union all
         select '03' col1 from dual union all
         select '04' col1 from dual 
        )
          
        
    My question
    How to join table1.col1 table2.col1? since they are different data types... .i tried to use To_char but then I got 0 zero,.
    is there is all the functions I can use?


    Thank you!!

    user642297 wrote:
    Hello experts,

    I have two tables...

    create table1
    (
    col1 varchar2(20)
    );
    
    create table2
    (
    col1 number(10)
    );  
    

    with their data as below

    Above, you said that table2.col1 was a NUMBER.
    Below, is a VARCHAR2:

    with table1 as
    (  select 'xx' col1 from dual union all
    select 'yy' col1  from dual union all
    select '01' col1  from dual union all
    select '02' col1  from dual union all
    select '03' col1  from dual union all
    select '04' col1  from dual
    ),table2 as
    (
    select '01' col1 from dual union all
    select '02' col1 from dual union all
    select '03' col1 from dual union all
    select '04' col1 from dual
    )
    

    Woudn't be a better approximation of your real tables:

       ),table2 as
        (
          select 1 col1 from dual union all
          select 2 col1 from dual union all
          select 3 col1 from dual union all
          select 4 col1 from dual
         )
    

    ?

    My question
    How to join table1.col1 table2.col1? since they are different data types... .i tried to use To_char but then I got 0 zero,.
    is there is all the functions I can use?

    Your postal code. I think the best way is to use TO_CHAR, but maybe you were using it differently.

    SELECT     *
    FROM     table1
    JOIN     table2     ON     NVL ( LTRIM (table1.col1, '0')
                       , '0'
                       )     = TO_CHAR (table2.col1)
    ;
    

    This assumes that table1.col1 never contains decimal points, unary + signs, exhibitors, or other things like that.
    He will be responsible for negative numbers, but if table1.col1 contains 0 in front after the sign less (for example '-0012' "), then the solution is a bit more complicated.

  • How interrogate in two tables

    Hi all
    How to query in two different tables? Use the following text

    SET_BLOCK_PROPERTY ('ins1', ONETIME_WHERE, ' series = "' |: OVERALL.) CODE | ''''); This works but for a single table if I want two tables and and display the information to the main form, for example... tables are referenced by a primary key constraint and foreign key.


    Sarah

    Published by: SarahSarahSarah on September 1, 2009 04:59

    Please try to create a relationship of block in your form.
    in the browser open the node of data blocks, then then INS1 node and click relationships.
    Click the green + * button on the left vertical toolbar.

    Block detail:
    PLATE type

    Deletions from Master:
    -In cascade (deletion details when the master is removed)

    Coordination:
    -Prevent the operation without a master

    Join:
    type (Word): REF
    do not select REF Object (this has nothing to do with your REF column!)

    Click OK and that's all.
    May you do not change or delete the new created triggers and program units to the
    you know what you're doing.

  • How to link two tables with a part of a cell value

    I have 1 column, which contains info like this "1 to 4 numbers - two words" in tableA

    for example

    985 - train series

    14 baby Doll

    874 piano keyboard

    6 - DVD player

    etc.

    In table B I have columns with the numbers of toys 1 and 2 which has the price.

    I want to write a query that gives me the number, name and price.

    But I don't know how to link part of the value in a cell with another table.

    I know that the database is not normalized, but I did not design and I have no permission to change.

    Kind regards

    What have you tried?

    Please read: Re: 2. How can I ask a question on the forums?

    Sounds to me like you just want to join the tables on a partial string, so to make you just extract the numbers from the table A Column1.

    for example

    TO_NUMBER (substr (A.col1, 1, instr(' ')-1))

  • JOIN the question... Join two tables without omitting lines

    I came across a problem that should be an easy fix (I hope), but I'm having a hard time to come up with a solution.

    Basically I have two tables, one with the actual amounts with the budget. I have to write a sql statement select that joins these tables together and includes all of their lines. I was able to join the tables by using JOIN, LEFT JOIN and RIGHT JOIN, but it always fails the lines I need.

    Below, I have examples of my tables (AMOUNT_TABLE and BUDGET_TABLE). For simplicity, I built the examples to show the same values in the first four columns, with the 5th and 6th columns (SUB_ACCOUNT, AMOUNT, BUDGET) as the only values that are different. My actual tables are not quite that simple, but I don't think it was relavent to this issue.

    AMOUNT_TABLE

    FISCAL_YEAR PERIOD ACCT_UNIT ACCOUNT SUB_ACCOUNT AMOUNT

    2013

    111111555555000010020131111115555551000100201311111155555520001002013111111555555300010020131111115555554000100

    BUDGET_TABLE

    FISCAL_YEAR PERIOD ACCT_UNIT ACCOUNT SUB_ACCOUNT BUDGET

    2013

    1111115555553000200201311111155555540002002013111111555555500020020131111115555556000200

    Here's what I hope. Note that SUB_ACCOUNTs 0000, 1000, and 2000 show without budget amounts since there is not a corresponding line in the BUDGET_TABLE. And same for SUB_ACCOUNTs 5000 and 6000, they show budgets with no amount because there is not a corresponding line in the AMOUNT_TABLE.

    (exit)

    FISCAL_YEAR PERIOD ACCT_UNIT ACCOUNT SUB_ACCOUNT AMOUNT BUDGET
    201311111155555500001000
    201311111155555510001000
    201311111155555520001000
    20131111115555553000100200
    20131111115555554000100200
    201311111155555550000200
    201311111155555560000200

    If all goes well, my question is clear. Any help on this would be greatly appreciated. Thanks in advance.

    Use the join ANSI - FULL OUTER JOIN syntax:

    with amount_table like)

    Select fiscal_year 2013, 1 period, 11111 acct_unit, 555555, 0000 sub_account, amount 100 of all the double union

    Select 2013,1,11111,555555,1000,100 from all the double union

    Select 2013,1,11111,555555,2000,100 from all the double union

    Select 2013,1,11111,555555,3000,100 from all the double union

    Select double 2013,1,11111,555555,4000,100

    ),

    budget_table like)

    Select 1 time, 11111 acct_unit, account 555555, sub_account 3000, 2013 fiscal_year, budget of 200 Union double all the

    Select 2013,1,11111,555555,4000,200 from all the double union

    Select 2013,1,11111,555555,5000,200 from all the double union

    Select double 2013,1,11111,555555,6000,200

    )

    Select nvl (a.fiscal_year, b.fiscal_year) fiscal_year,

    period of NVL (a.period, b.period),

    NVL (a.acct_unit, b.acct_unit) acct_unit.

    account of NVL (a.Account, b.Account),

    NVL (a.sub_account, b.sub_account) sub_account.

    Amount NVL(a.amount,0),

    NVL(b.budget,0) budget

    of amount_table one

    full join

    budget_table b

    on)

    a.Fiscal_Year = b.fiscal_year

    and

    a.period = b.period

    and

    a.acct_unit = b.acct_unit

    and

    a.Account = b.account

    and

    a.sub_account = b.sub_account

    )

    /

    FISCAL_YEAR PERIOD ACCT_UNIT ACCOUNT SUB_ACCOUNT AMOUNT BUDGET
    ----------- ---------- ---------- ---------- ----------- ---------- ----------
    2013 1 11111 555555 0 100 0
    2013 1 11111 555555 1000 100 0
    2013 1 11111 555555 2000 100 0
    2013 1 11111 555555 3000 100 200
    2013 1 11111 555555 4000 100 200
    2013 1 11111 555555 6000 0 200
    2013 1 11111 555555 5000 0 200

    7 selected lines.

    SQL >

    SY.

  • How to delete all TABLEs in the schema SYS that are created from 09:15?

    Unfortunately a script created a lot of tables in the diagram (= SYS) and bad Tablespace (= SYSTEM).

    How can I delete all TABLES that are created inTablespace = SYSTEM and SCHEMA = SYS (in a DDL command)
    respectively for the past 3 hours from 09:15 to 25 Sep 2011?

    Alternative: How can I move these tables in another schema (for example ATEST) and Tablespace (USERS)?
    Is this possible with Oracle XE or Oracle Enterprise?

    Peter

    You can use ALTER TABLE... MOVE. It offers a TABLESPACE clause, which allows you to choose a different tablespace as target. Refer to the documentation for your version of the database.

  • foreign key referencing the table in different schema

    I create a foreign key for the table in the schema A a table to diagram B.

    I do that by grant references (column name) on the name of the table to username;


    is there any drawback/disadvantage in the creation of foreign keys referencing tables in another schema?

    Not as such, no.

    Generally, you want to check a second time when you are in this kind of situation that the two tables really belong in different schemas. It should be relatively rare to find a child table that belongs to a different schema than the parent. Sometimes, but it should be an exception, not the rule.

    Justin

  • How to create a table in a schema in the SOA database

    Hello

    can you please guide me how to create a table looks under custom schema available in the SOA database

    Thank you

    Valsaint

    Hello

    1. use JDeveloper to connect to your schema custom: view > Database > Database Navigator > new connection

    2. set the mpdel of your table column names, types of data, constraints (primary key, not null, foreign key, etc..)

    3. use this simplified tutorial to create the table according to your model of table create statement - Oracle/PLSQL: CREATE TABLE statement

    4. execute the statement in the SQL of JDeveloper journal for the custom connection (point 1 above).

    Let me know if you need help!

    HTH,

    A.

Maybe you are looking for