Incompatibility of County to join condition

Hello

I do a join on the relational tables (select * T_ZIP_CODE - save 47561 County and SELECT * OF P_GEODATA - number of records 42451) using the below sql # 1 (where a.zip_cde = b.zip_cde) I'm number of records as 41979 and while I am executing sql # 2 (difference of 2 SQL is condition where a.zip_cde <>b.zip_cde) get the number of records = 1773815507

For SQL # 2 I should get the number of records about 541

Can someone me please suggest that if something is wrong.

SQL # 1

Select

b.ZIP_CDE,

a.ZIP_CDE_STRT_DTE,

b.TLPHN_AREA_CDE,

b.POP_LVL_CDE,

b.PMSA_MSA_NECMA_CDE,

b.FIPS_PRMRY_CNTY_CDE,

b.CNTY_NAM_PRMY,

b.FIPS_ADDL_CNTY_1_CDE,

b.CNTY_NAM_1,

b.FIPS_ADDL_CNTY_2_CDE,

b.CNTY_NAM_2,

b.FIPS_ADDL_CNTY_3_CDE,

b.CNTY_NAM_3,

b.FIPS_ADDL_CNTY_4_CDE,

b.CNTY_NAM_4,

b.DMA_CDE,

b.DMA_NAM,

b.CBSA_CDE,

b.CBSA_TYP,

b.MSA_DIV_CDE,

b.CSA_CDE,

b.CMSA_CDE

T_ZIP_CODE a, P_GEODATA B where a.zip_cde = b.zip_cde

and CURRENT_DATE < ZIP_CDE_END_DTE

record COUNT - 41979

Select

b.ZIP_CDE,

a.ZIP_CDE_STRT_DTE,

b.TLPHN_AREA_CDE,

b.POP_LVL_CDE,

b.PMSA_MSA_NECMA_CDE,

b.FIPS_PRMRY_CNTY_CDE,

b.CNTY_NAM_PRMY,

b.FIPS_ADDL_CNTY_1_CDE,

b.CNTY_NAM_1,

b.FIPS_ADDL_CNTY_2_CDE,

b.CNTY_NAM_2,

b.FIPS_ADDL_CNTY_3_CDE,

b.CNTY_NAM_3,

b.FIPS_ADDL_CNTY_4_CDE,

b.CNTY_NAM_4,

b.DMA_CDE,

b.DMA_NAM,

b.CBSA_CDE,

b.CBSA_TYP,

b.MSA_DIV_CDE,

b.CSA_CDE,

b.CMSA_CDE

T_ZIP_CODE a, P_GEODATA B where a.zip_cde <>b.zip_cde

and CURRENT_DATE < ZIP_CDE_END_DTE

record count = 1773815507

Thank you!

3058870 wrote:

Hello

I do a join on the relational tables (select * T_ZIP_CODE - save 47561 County and SELECT * OF P_GEODATA - number of records 42451) using the below sql # 1 (where a.zip_cde = b.zip_cde) I'm number of records as 41979 and while I am executing sql # 2 (difference of 2 SQL is condition where a.zip_cde <> b.zip_cde) get the number of records = 1773815507

For SQL # 2 I should get the number of records about 541

Why? Suppose table A has three lines id = 1,2,3 and table B has 4 lines, id = 1,2,3,4. A.id = b.id condition will return 3 rows. But condition a.id! = b.id will not return 1 row. Why? A.id condition! = b.id will be true for:

a.ID = b.id 1 = 2

a.ID = b.id 1 = 3

a.ID = b.id 1 = 4

a.ID = b.id 2 = 1

a.ID = b.id 2 = 3

a.ID = b.id 2 = 4

a.ID = b.id 3 = 1

a.ID = b.id 3 = 2

a.ID = b.id 3 = 4

A.ID Yes! = b.id will not return 1, but 9 lines.

SY.

Tags: Database

Similar Questions

  • CASE statement in a join condition


    Hello

    I'm stuck in this part of the code, where I use CASES in a join condition. I work in Teradata, so I can't use "DECODE".

    LEFT JOIN V610413. TEAM_ASSIGNMENTS your

    -C.firm_id = your. FirmId

    ONE BOX WHEN your. FirmId = c.firm_id THEN your. FirmId = c.firm_id

    WHEN your. FirmId <>c.firm_id THEN your. FirmId = 'no value '.

    END

    AND c.stateId = ta.stateId

    Please advice

    LEFT JOIN V610413. TEAM_ASSIGNMENTS your

    We'RE your. FirmId = CASE WHEN your. FirmId = c.firm_id THEN c.firm_id

    WHEN your. FirmId <> c.firm_id THEN 'no value '.

    END

    AND c.stateId = ta.stateId

  • OLAP cube - complex join condition

    Hi Experts,

    I requires a complex join between the dimension and cube.

    Requirement goes like this-

    We have a dimension to the date level-
    January 1, 2011
    January 2, 2011
    ...
    .. and so on.

    The fact table is not a matching surrogate key, but it has valid_from_date and valid_to_date that are stamps.

    I need to join these two to reach the condition readings - where dim.date between trunc (valid_from_date) and trunc (valid_to_date).

    Is it possible/feasible? Enjoyed your responses.

    Best regards, Marion

    You should be able to set a condition like this in the field "Join Condition" of the mapping pane cube in AWM. You would need to qualify table names to be something like this

    dim_table.date between trunc(fact_table.valid_from_date) and trunc(fact_table.valid_to_date).
    

    The only restriction to this approach is that you will not be able to partition on the time dimension for this cube due to the complexity of the condition.

    As an alternative, you can define a SQL view that joined your fact table in your time dimension table using the same condition. You map the cube on this point of view, in which case the restriction on partitioning goes.

  • Join condition of cube and other mapping missing mapping

    Hi David,

    I have a strange problem... After the creation of cube mapping tables defning and physical objects joins and the change of my mapping intermittently disappears... Not being able to trace what's happening. Is this a known bug or nothing is done correctly?

    Enjoy your previous answer.

    Thank you very much
    Paiva

    A "mapping" is a term of olap product management which means that the cube is not mapped to the level the fact sheet. For example, suppose you have tables like this

    CREATE TABLE SALES_FACT
    (
      DAY_OF_SALE DATE,
      PRODUCT_ID NUMBER,
      UNITS NUMBER,
      COST NUMBER
    )
    
    CREATE TABLE TIME
    (
      DAY DATE,
      MONTH NUMBER,
      QUARTER NUMBER,
      YEAR NUMBER
    )
    

    Suppose you want to analyze the data only at the level of the MONTH and more. In this case, you must set a time of hierarchy which includes levels MONTHS->->-> ALL_TIME YEAR QUARTER and you would need to define a join condition between SALES_FACT and TIME of the form

    SALES_FACT.DAY_OF_SALE = TIME.DAY
    

    This is sometimes called a "mapping" because it maps data in the AW to a higher level than what is stored in the fact (for example, the MONTHS instead of DAYS).

  • try to find the join condition

    Hello
    Does anyone know what table in the working repository stores the join interface conditions?



    Thanks in advance
    REDA

    Raj,

    You can reach SNP_TXT, SNP_POP_CLAUSE and SNP_POP for the join conditions.

    Select sp.pop_name, snp_pop sp, spc snp_pop_clause st snp_txt st.txt
    where SP. I_POP = SPC. I_POP
    and MS. POP_NAME = "YOUR_INTERFACE_NAME".
    and SPC. I_TXT_SQL = ST. I_TXT

    See if that helps you.

  • Join does not work for NULL values on the join condition

    Hello

    I have the following problem.

    SQL > select * from a;

    X Y
    ---------- --------------------
    1
    2
    3
    4

    SQL > select * from b;

    A:
    ---------- --------------------
    1
    2



    SQL > select f.x, f.y, s.b in f, s b
    2 where f.x = s.b (+);
    X Y B
    ---------- -------------------- ----------
    1 1
    2 2
    4
    3




    SQL > select f.x, f.y, s.b in f, s b
    2 where f.x = s.b (+)
    3 and f.y = s.y;

    no selected line


    So now if I include a join condition more where null = null situation arises, it's working now.
    Just tell her not to treat (1 and null) (1 and null) are the same.
    What is the solution. This is an expected behavior.


    Thank you
    Pramod Garre

    Pramod salvation,

    Another way to use the outer join is,

    Select f.x, f.y, s.b
    of a, f, s b
    where f.x = s.b (+)
    and nvl(f.y,0) = nvl (s.y (+), 0);

    Hope this will help you.

    Thank you
    Amit

  • Error when you try to validate the Join Condition

    In a map, I include a Carpenter and set the join condition. By clicking on the button post, I got the following error: "an error occurred during validation of the expression. Bad expression return type. »

    At first, we thought it was a problem when you create a new map. However, we returned to the existing mappings already validated successfully and each join now returns this error OWB. This occurs for each installed user with OWB. Mapping validate successfully in the end, but the join itself will not be validated during development.

    We currently use customer 10.2.0.4.36 OWB and OWB 10.2.0.4.0 repository. The latest patch is causing this problem? A way to solve this problem?

    Thank you
    Jennifer

    It's a bug, not a feature:

     09/17/08 03:26 pm
     Version & machine info: ========================
    OWB Client/OS: OWB 10.2.0.4.36/Windows
    OWB Design Repository Version: 10.2.0.4
    Runtime Repository Server Platform/Version: Windows XP/10.2.0.4.36
    Oracle Database/OS : 10.2.0.3/Windows XP
    SOURCE & TARGET on the same machine or different machine ? yes
    SOURCE database version/OS: 10.2.0.3
    TARGET database version/OS: 10.2.0.3 .
    Problem Description ======================== .
    Filter and Join Mapping Expressions always fail the Validation Check with the  following dialogue: "An error occured during expression validation. Bad expression return type". It does not matter what the expression is. . This is a new bug in 10.2.0.4. The same exppressions validate successfully in  10.2.0.3 . The code generates and deploys successfully after this message. . . . Reproducible Case (For All bugs) ================================= . 1)START OWB Design and connect  2)Import the uploaded OWB 10.2.0.4 MDL file: expression_validate_bug.mdl  3)OPEN the Project TESTCASE 4)OPEN The Oracle Module EXPRESSION_VALIDATE_BUG 5)OPEN the mapping EXPRESSION_VALIDATE_ERROR 8)Highlight the Filter 9)Open the Filter Condition Doialogue Box. 10)Select the validate button. 11)Observe error.
    
    BugNo: 7417869 vom 17.09.08
    

    Kind regards
    Detlef

  • Difference in using the join condition

    Hello

    Can someone please explain the difference between below towing queries using joins.

    First, I used additional where condition on the statement.

    Select count (*) from table1 t1

    Join external table2 t2 on t1.c1 = t2.c2 = 'ZZZ' and t2.c1 left

    In the second I used it in where condition.

    Select count (*) from table1 t1

    T1.C1 = t2.c1 left outer join table2 t2

    where t2.c2 = 'ZZZ'

    Although, in both cases using the Iam Left outer join that I get different results. Someone please you suggest on this?

    Thanks in advance

    In the first case, Oracle selects a row in the DEPT table and looking for lines in the EMP table for the same service as employees in the DEPT table and job MANAGER. If it does not find these lines it still selects lines of the DEPT table joined with the line of the EMP table where all column values are NULL. That's why first query returns with NULL ename OPERATIONS Department. Second query selects a row in the DEPT table and research lines in the EMP table employees in the same Department in Dept. Similarly it OPERATIONS Department joins with ename and use NULL NULL. But the second query is the WHERE clause is applied after the tables are joined. So now we are looking for JOB = 'MANAGER' in the already joined tables and of course will not select row to the Department of OPERATIONS. In other words, second request denies the need for external since join together there is no external attached lines will always be NULL job.

    SY.

  • join condition

    Hi masters.

    I have 4 tables... I need to join properly... I joined like that... Please let me know... is this correct or not?

    SELECT

    SEPARATE

    A.EMPLOYEE_NUMBER Employee_Number,

    Contact_Employee_Number NULL,

    A.last_name Last_Name,

    A.first_name name,

    A.TITLE title,

    A.NATIONAL_IDENTIFIER National_Identifier,

    A.DATE_OF_BIRTH Birth_Date,

    A.SEX gender,

    fn_ret_R12_lov('Lookup-TITLE',B.CONTACT_TYPE) type_contact,

    Relationship of NULL,

    Relationship_From NULL,

    Relationship_To NULL,

    fn_ret_R12_lov ("search-CONTACT_TYPES', A.MIDDLE_NAMES ') Middle_Names,.

    fn_ret_R12_lov('Lookup-CONTACT',B.PRIMARY_CONTACT_FLAG) Primary_Contact,

    B.RLTD_PER_RSDS_W_DSGNTR_FLAG Shared_Residence,

    B.BENEFICIARY_FLAG beneficiary,

    Dependent on B.DEPENDENT_FLAG,

    B.PERSONAL_FLAG Personal_Relationship,

    C.DATE_FROM Address_Date_From,

    C.DATE_TO Address_Date_To,

    C.STYLE mandatory,

    Mandatory C.ADDRESS_TYPE

    C.PRIMARY_FLAG,

    C.ADDRESS_LINE1 Ligne_adresse_1,

    C.ADDRESS_LINE2 Ligne_adresse_2,

    fn_ret_R12_lov('Lookup-ADDRESS_TYPE',C.ADDRESS_LINE3) Address_Line_3,

    City C.REGION_1

    County of C.REGION_2,

    C.COUNTRY country,

    C.POSTAL_CODE Post_Code,

    D.DATE_FROM Phone1_Date_From,

    fn_ret_R12_lov('Lookup-GB_COUNTY',D.DATE_TO) Phone1_Date_To,

    fn_ret_R12_lov('Lookup-PQP_US_COUNTRY_TRANSLATE',D.PHONE_TYPE) Phone1_Type,

    D.PHONE_NUMBER Phone1_Number,

    D.DATE_FROM Phone2_Date_From,

    D.DATE_TO Phone2_Date_To,

    fn_ret_R12_lov('Lookup-D'.PHONE_TYPE) Phone2_Type,

    D.PHONE_NUMBER Phone2_Number,

    D.DATE_FROM Phone3_Date_From,

    D.DATE_TO Phone3_Date_To,

    fn_ret_R12_lov('Lookup-D'.PHONE_TYPE) Phone3_Type,

    D.PHONE_NUMBER Phone3_Number,

    Emergency_Flag NULL

    Of

    PER_ALL_PEOPLE_F, A.

    B PER_CONTACT_RELATIONSHIPS,

    PER_ADDRESSES C.

    PER_PHONES D

    WHERE

    A.PERSON_ID = B.PERSON_ID

    AND A.PERSON_ID = C.PERSON_ID

    AND A.PARTY_ID = D.PARTY_ID;

    Please find below the table desc... Please notify.

    / / DESC

    -------

    DESC PER_ALL_PEOPLE_F
    ------------------------------------------
    Name of Type Null

    ----------------------------------------------------
    PERSON_ID NOT NULL NUMBER (10)

    EFFECTIVE_START_DATE NOT NULL DATE
    EFFECTIVE_END_DATE NOT NULL DATE
    BUSINESS_GROUP_ID NOT NULL NUMBER (15)

    PERSON_TYPE_ID NOT NULL NUMBER (15)
    EMPLOYEE_NUMBER VARCHAR2 (30)

    EXPENSE_CHECK_SEND_TO_ADDRESS VARCHAR2 (30)

    PARTY_ID NUMBER (15)

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

    DESC PER_CONTACT_RELATIONSHIPS
    -------------------------------

    Name of Type Null
    ---------------------------------------------
    CONTACT_RELATIONSHIP_ID NOT NULL NUMBER (15)
    BUSINESS_GROUP_ID NOT NULL NUMBER (15)
    PERSON_ID NOT NULL NUMBER (10)
    CONTACT_PERSON_ID NOT NULL NUMBER (10)
    TYPE_CONTACT NOT NULL VARCHAR2 (30)

    PARTY_ID NUMBER (15)

    CONT_INFORMATION_CATEGORY VARCHAR2 (30)

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

    PER_ADDRESSES DESC;
    ----------------------
    Name of Type Null
    ADDRESS_ID NOT NULL NUMBER (15)
    BUSINESS_GROUP_ID NUMBER (15)
    PERSON_ID NUMBER (10)
    OBJECT_VERSION_NUMBER NOT NULL NUMBER (9)
    PARTY_ID NUMBER (15)


    PER_phones DESC;
    ------------------
    Name of Type Null
    -------------------------------------------
    PHONE_ID NOT NULL NUMBER (15)
    DATE_FROM NOT NULL DATE
    DATE OF DATE_TO
    PHONE_TYPE NOT NULL VARCHAR2 (30)
    PHONE_NUMBER NOT NULL VARCHAR2 (60)
    PARENT_ID NUMBER (15)
    PARENT_TABLE VARCHAR2 (30)
    ATTRIBUTE_CATEGORY VARCHAR2 (30)

    PARTY_ID NUMBER (15)
    VARCHAR2 (30) OF VALIDITY

    This section:

    Of

    PER_ALL_PEOPLE_F, A.

    B PER_CONTACT_RELATIONSHIPS,

    PER_ADDRESSES C.

    PER_PHONES D

    WHERE

    A.PERSON_ID = B.PERSON_ID

    AND A.PERSON_ID = C.PERSON_ID

    AND A.PARTY_ID = D.PARTY_ID;

    Changes to something like this:

    Of

    PER_ALL_PEOPLE_F, A.

    B PER_CONTACT_RELATIONSHIPS,

    PER_ADDRESSES C.

    PER_PHONES D

    WHERE

    A.PERSON_ID = B.PERSON_ID

    AND A.PERSON_ID = C.PERSON_ID

    AND A.PARTY_ID = D.PARTY_ID(+);

    You can also use standard ANSI joins... (but they may get a little more complicated sometimes)

  • Join conditional

    Hello
    I need to write a select with a join parole, similar to the following:
    select ...
    from table1 a
      join table2 b on l.id= b.prod_id
      join table3 c on c.tip in case
                       when <some_value> in ('RESPINSA', 'ANULAT', 'ANULATA') then (select cod from tipuri_mesaj 
                                                                                                                    where stadiu_trimitere in ('RESPINSA', 'ANULAT', 'ANULATA')
                                                                                                                )
                      else -- here I need c.tip "=" <a_value> , not "in"
                                       
    Is it possible to do? If the first when is true, it must search by using "c.tip (...)", otherwise the condition should be "c.tip =...". »

    Thank you!

    Hello

    I still don't see examples of data or expected results, then I will use the tables in the scott schema.
    Looks like you are trying to do something like this:

    SELECT       e.ename
    ,       e.job
    ,        e.deptno     AS e_deptno
    ,       d.deptno     AS d_deptno
    ,       d.dname
    FROM       scott.emp   e
    JOIN       scott.dept  d   ON   (    d.dname  IN ('ACCOUNTING', 'FIRBOLIG')
                                  AND  'X' = (
                                             SELECT  dummy
                                  FROM    dual
                                          )
                          )
                     OR   (    d.dname  NOT IN ('ACCOUNTING', 'FIRBOLIG')
                          AND  d.deptno = e.deptno
                          )
    WHERE       e.ename   < 'J'      -- Just to reduce quantity.  Acutally says "less than 'J'".  See note below
    ;
    

    Output:

    ENAME      JOB         E_DEPTNO   D_DEPTNO DNAME
    ---------- --------- ---------- ---------- --------------
    ALLEN      SALESMAN          30         10 ACCOUNTING
    BLAKE      MANAGER           30         10 ACCOUNTING
    CLARK      MANAGER           10         10 ACCOUNTING
    ADAMS      CLERK             20         10 ACCOUNTING
    FORD       ANALYST           20         10 ACCOUNTING
    ADAMS      CLERK             20         20 RESEARCH
    FORD       ANALYST           20         20 RESEARCH
    ALLEN      SALESMAN          30         30 SALES
    BLAKE      MANAGER           30         30 SALES
    

    As you can see, when dname = 'ACCOUNTING', the subquery on dual is performed, and, since this condition is TRUE, all 5 scott.emp ranks are supposed to match, regardless of their deptnos. When dname is not "ACCOUNTING", then lines are considered to match ony if the deptnos are the same.

    Published by: Frank Kulash, 19 April 2013 09:24

    This site does not display all of my request.
    The WHERE clause is supposed to be

    WHERE the e.ename < 'J '.

  • Need help with the JOIN condition

    I have two tables tb1 and tb2. They join on two columns, namely, plan_name and activity_name. I must, however, ensure the following conditions by joining:

    1. pick up all the records that link between tb1 and tb2.

    2. If the tb1.plan_name is "Activity Adhoc" and then choose the lines that converge with tb2. Also pick up lines that do not join with tb2 where plan_name = 'Ad hoc activity'. For example:
    TB1 have 2 folders with plan_name Adhoc Acitivity
    plan_name activity_name
    Adhoc activity A1
    Adhoc activity A2
    TB2 has 1 plug with plan_name activity Adhoc
    plan_name activity_name
    Adhoc activity A1

    then the two records of tb1 should be taken. in other Assembly documents where plan_name <>"Adhoc Acitivity" should also be taken
    with tb1 as
    (
    select 'Adhoc Activity' plan_name,'A1' activity_name from dual union all
    select 'Adhoc Activity' plan_name,'A2' activity_name from dual union all
    select 'another Activity' plan_name,'A2' activity_name from  dual union all
    select 'Some another Activity' plan_name,'A2' activity_name from dual
    ),
    tb2 as
    (
    select 'Adhoc Activity' plan_name,'A1' activity_name from  dual union all
    --select 'Adhoc Activity' plan_name,'A2' activity_name dual union all
    select 'another Activity' plan_name,'A2' activity_name from  dual --union all
    --select 'Some another Activity' plan_name,'A2' activity_name dual
    )
    select *
    from(
       select a.plan_name a_plan_name,b.plan_name b_plan_name
       from tb1 a,tb2 b
       where a.plan_name = b.plan_name(+)
       and a.activity_name = b.activity_name(+)
         )
    where (a_plan_name = 'Adhoc Activity'  or b_plan_name is not null);
    
    A_PLAN_NAME           B_PLAN_NAME
    --------------------- ----------------
    Adhoc Activity        Adhoc Activity
    another Activity      another Activity
    Adhoc Activity                         
    

    Published by: JAC on November 19, 2012 10:27

  • dynamic join condition

     create table stg1 (x number)
     
     insert into stg1 values(7134472074);
     
     insert into stg1 values (2814278721);
    
    
     create table stg2 (x number)
     
     insert into stg2 values(7134472074);
     
     insert into stg2 values (2814278721);
    
    commit;
    based on some condition, I want to join either 7134472074 or 2814278721
    declare
     x varchar2(100);
     y varchar2(10) := 'n';
     begin
     select b.x
     into x
     from stg1 a, stg2 b
     where a.x = decode(y,'n',7134472074,2814278721);
     
     dbms_output.put_line(x);
     
     end;
     /
    I get ORA-01422: exact extraction returns more number of error rows, requested the audit of the State and adhere to be dynamically?

    If so, how?

    >
    I want to join
    >
    Your query is not a join specified for Oraclel is a CARTESIAN join and joins all ranks to stg1 stg2.

    That's why the query returns two rows, and you're trying to put the two values into 'x '.

    Add join to stg2 the query does not return a single line. Instead of simply

    where a.x = decode(y,'n',7134472074,2814278721);
    

    Add join

    where a.x = decode(y,'n',7134472074,2814278721)
        and b.x = a.x;
     
    
  • Update of several lines using the join condition

    Hi all

    CREATE OR REPLACE
    PROCEDURE update_t
    IS

    BEGIN
    SheikYerbouti IN (SELECT EMPLOYEE_ID, FIRST_NAME, LAST_NAME FROM hr.employees)
    LOOP
    UPDATE
    HR.employees1
    SET
    FOCA =)
    Select concat (FIRST_NAME, LAST_NAME) in the hr.employees where SheikYerbouti. EMPLOYEE_ID = 197);
    END LOOP;
    END update_t;
    /

    I'm trying to update column Foca Employees1 table. When I run this procedure, I get the error

    Error report:
    ORA-01427: einreihig subquery returns multiple rows
    ORA-06512: at "SYSTEM. UPDATE_T", line 13
    ORA-06512: at line 1
    01427 00000 - "einreihig subquery returns several lines.

    Please let me know a solution for this.

    Thank you
    Mathon

    Hello Mathieu,
    in your internal SQL result set is not limited to just one line.
    Try this

    UPDATE hr.employees1 SET
    FIRST_LAST= (select concat(FIRST_NAME,LAST_NAME) from hr.employees where emp_rec.EMPLOYEE_ID=hr.employees.employee_id);
    

    Your version had no restrictions on selected lines of hr.employees. You gave a where condition clause that is not related to the query.

    The best solution for your problem is to avoid completely any PL/SQL loop. You can try something like this:

    update
       (select
           e1.first_last,
           e.first_name,
           e.last_name
        from
           hr.employees1 e1,
           hr.employees e
        where
           e1.employee_id=e.employee_id) set
       first_last=first_name||last_name;
    

    But beware, the updates on the joints work only under certain restrictions. The key of the table to be updated must be the join key. (key preserved is the word to look for).

    Hope that helps,
    dhalek

  • Join conditions, update a table

    Hello

    I created a table of choice in the apex, so my Dispatcher column, moved to the new table. (first time doing so)

    I created again the dispatcher of the column in the first table.

    I have the following code:

    SELECT R.DISPATCHER, B.DISPATCHER

    OF GCAT_V3 R JOIN GCAT_DISPATCHER_LOOKUP B

    ON R.DISPATCHER_ID = B.DISPATCHER_ID

    DISPATCHER DISPATCHER
    -SU. [email protected]
    -SU. [email protected]
    -SU. [email protected]
    -SU. [email protected]

    I need to copy the data back.

    Basically, what I have in the column that b.Dispatcher must be copied to another column dispatcher.

    Any ideas?

    Kind regards

    Leonard

    Hi, Leonard,

    Whenever you have a question, please post a small example of data (CREATE TABLE and only relevant columns, INSERT statements) for all of the tables involved and the accurate results you want from this data, so that people who want to help you can recreate the problem and test their ideas.

    If you ask about a DML operation, such as UPDATE, then INSERT statements, you post should show what looks like the tables before the DML, and the results will be the content of the table changed after the DML.

    Explain, using specific examples, how you get these results from these data.

    Always say what version of Oracle you are using (for example, 11.2.0.2.0).

    See the FAQ forum: Re: 2. How can I ask a question on the forums?

    You can use the UPDATE or MERGE to copy data from a table to the existing lines in another.  For example:

    UPDATE gcat_v3 r

    SET dispactcher =)

    SELECT b.dispatcher

    OF gcat_dispatcher_lookup b

    WHERE b.dispatcher_id = r.dispatcher_id

    )

    ;

    The above statement assumes that dispatcher_id is unique in gcat_dispatcher_lookup; But there is no need to be unique in gcat_v3.

  • use of rownum in join condition

    Hello

    I have three tables OBI_CONSOL_RC_HIER_V and pmt_fact and OBI_INVOICE_DIST_V.
    common columns b/w OBI_CONSOL_RC_HIER_V and pmt_fact is resp_center_id and company_id and geography Id
    common columns b/w pmt_fact and OBI_INVOICE_DIST_V is Invoice_account_num

    now, I want to display the name of the provider of OBI_CONSOL_RC_HIER_V and INV_DIST_AMOUNT of OBI_INVOICE_DIST_V and also, she should return top 10 suppliers based on their INV_DIST_AMOUNT.

    Please help me.


    Concerning
    RAM

    Assuming that there is a 1:1 relationship between the suppliers and invoices, this should be fairly simple to resolve:

    select supplier_name
             , inv_dist_amount
    from (
        select OBI_CONSOL_RC_HIER_V.supplier_name
                 , OBI_INVOICE_DIST_V.inv_dist_amount
                 , rank() over (order by OBI_INVOICE_DIST_V.inv_dist_amount desc) rnk
        from OBI_CONSOL_RC_HIER_V
                 join PMT_FACT on (OBI_CONSOL_RC_HIER_V.resp_center_id  = PMT_FACT.company_id
                                   and OBI_CONSOL_RC_HIER_V.resp_center_id = PMT_FACT.company_id
                                   and OBI_CONSOL_RC_HIER_V.Geography_id = PMT_FACT.Geography_id )
                 join OBI_INVOICE_DIST_V on (OBI_INVOICE_DIST_V.Invoice_account_num = PMT_FACT.Invoice_account_num )
        where rnk <=10
        )
    /
    

    If there is a different relationship, you need to explain it. According to Frank, give us more information more you have chances to get a useful and relevant response.

    Cheers, APC

Maybe you are looking for