A simple join

Hello

Is someone can you please tell me if I can use the concatenation of (|) operator to check as below Query2 NULL values? It will enhance any show in the course of using many '' AND '' conditions as below Query1?

In addition, I check for NULL values on which different data such as Varchar, Date and number, if you concatenation operator to do the work?

Instead of using "AND" a lot of conditions, is there a better technique to check if all the columns below are NULLs?

Query1

SELECT X.ENAME, Y.DNAME

TABLE1, TABLE2 X Y

WHERE X.ID = Y.ID

AND X.COMM IS NULL

AND Y.MGR IS NULL

AND X.END_DATE IS NULL

AND Y.DNUM IS NULL

Query2

SELECT X.ENAME, Y.DNAME

TABLE1, TABLE2 X Y

WHERE X.ID = Y.ID

AND X.COMM: Y.Mgr: X.END_DATE: Y.DNUM is null


Thanks in advance!

VAMSi.

Maybe (trying to avoid the implicit conversions)

SELECT X.ENAME, Y.DNAME

TABLE 1 X,

TABLE2 Y

WHERE X.ID = Y.ID

AND coalesce (to_char (X.COMM),

TO_CHAR (Y.Mgr),

TO_CHAR (X.END_DATE, 'yyyymmdd'),

TO_CHAR (Y.dnum)

) IS NULL


Concerning

Etbin

Tags: Database

Similar Questions

  • Functions of outer join left as simple join

    I created two views SCO_REQGROSSLINES_V and SCO_REQLINESCOMPLETE on Oracle applications tables base. Our company applies the following identity rules: the gross number of rows is always greater than or equal number of demand lines. (Full, I mean delivered.)

    Each view has a key named DATESUBINV_KEY built a date of the operation and the code subinventory using this logic:

    TO_CHAR (TRUNC (transaction_date), 'YYYYMMDD') | subinventory_code

    On 03-SEP-2010 a user has created a demand with a line item for the material of the HEAT subinventory who did not. This row is returned in the result set when I ask about SCO_REQGROSSLINES_V but does NOT return when I ask about SCO_REQLINESCOMPLETE. So far so good.

    When I run either of the left outer joins following, I don't get the line for the line for HEAT subinventory 03-SEP-2010:

    Select rgl.trxn_date
    rgl.subinventory
    rgl.line_count gross_line_count
    rgl.ext_prc gross_value
    rlc.line_count lines_filled
    rlc.ext_prc lines_filled_value
    of SCO_REQGROSSLINES_V vö outer join left sco_reqlinescomplete_v rlc
    ON rgl.datesubinv_key = rlc.datesubinv_key
    where vo. TRXN_DATE BETWEEN to_date('29-AUG-2010') AND to_date('04-SEP-2010')
    and rlc.trxn_date BETWEEN to_date('29-AUG-2010') AND to_date('04-SEP-2010')
    order of rgl.trxn_date, rgl.subinventory

    Select rgl.trxn_date, rgl.subinventory
    rgl.line_count gross_line_count
    rgl.ext_prc gross_value
    rlc.line_count lines_filled
    rlc.ext_prc lines_filled_value
    of SCO_REQGROSSLINES_V vo
    sco_reqlinescomplete_v rlc
    where vo. TRXN_DATE BETWEEN to_date('29-AUG-2010') AND to_date('04-SEP-2010')
    and rlc.trxn_date BETWEEN to_date('29-AUG-2010') AND to_date('04-SEP-2010')
    AND rgl.datesubinv_key = rlc.datesubinv_key (+)
    order of rgl.trxn_date, rgl.subinventory

    Question: Why the left outer joins is would work as a simple join on DATESUBINV_KEY? Do the keys function differently from the keys defined in the data dictionary views? If they do how these keys work as data dictionary keys?

    Hello

    The WHERE clause is applied after the outer join is complete. In your example, Vo will be in the game even if they have no match in rlc. In this case, all columns of rlc will be NULL.
    Okay, so you have these lines containing data from vo but NULL values, where the rlc data was supposed to go. Now it's time to start the WHERE clause. You then apply that conditions in the WHERE clause:

    AND     rlc.trxn_date BETWEEN ...
    

    NULL is between what whether, if the line the prodeuced the outer join is rejected.

    All the columns in involivn conditions of rlc probably needs to be part of the join condition, not the WHERE clause.
    For example, in you first ask the FROM and WHERE clauses can be:

    FROM          sco_reqgrosslines_v      rgl
    LEFT OUTER JOIN  sco_reqlinescomplete_v  rlc  ON    rgl.datesubinv_key   = rlc.datesubinv_key
                                            AND   rlc.trxn_date       BETWEEN TO_DATE ( '29-AUG-2010'
                                                                        , 'DD-MON-YYYY'
                                                            )
                                                  AND       TO_DATE ( '04-SEP-2010'
                                                              , 'DD-MON-YYYY'
                                                            )
    WHERE   rgl.trxn_date     BETWEEN TO_DATE ( '29-AUG-2010'
                             , 'DD-MON-YYYY'
                             )
                   AND     TO_DATE ( '04-SEP-2010'
                             , 'DD-MON-YYYY'
                             )
    

    Always use (at least) two arguments when calling TO_DATE.

    Conditions that involve only VO can be in the WHERE clause, but if all the rlc conditions in the WHERE clause, then the effect will be the same as a join internally.

    It is no difference between tables and views (or subqueries) in this regard: the same thing would happen, whether it is vo and rlc really tables or not.

  • Simple join question

    Hi guys, I'm confused.

    I was always told that one table can have ONLY 1 primary key. is this true or false? Or a table can cause several primary keys?

    Second question is, if I join two tables that are formed as a result of columns.

    Table 1:
    Account_number
    Account_create_month
    Customer_address

    Table 2:
    Account_number
    Account_create_month
    Customer_phone

    Should I join on account_number AND account_create_month? If yes why? and why not? Sorry if this is a stupid question. I'm just very confused. Thank you

    Hello

    Z KHAN wrote:
    Hi guys, I'm confused.

    I was always told that one table can have ONLY 1 primary key. is this true or false? Or a table can cause several primary keys?

    A table can have 1 primary key. There may be any number of columns (1, 2, 3 or more) in the primary key.
    A table can contain any number of unique keys.

    Second question is, if I join two tables that are formed as a result of columns.

    Table 1:
    Account_number
    Account_create_month
    Customer_address

    Table 2:
    Account_number
    Account_create_month
    Customer_phone

    Should I join on account_number AND account_create_month? If yes why? and why not? Sorry if this is a stupid question. I'm just very confused. Thank you

    No, you do not have to connect using the two. If you use the two in a join given or not depends on what the data means, and what results you want.

  • Why left outer join with a table gives me more lines?

    Hi gurus,

    I can see "view_a" and a table 'table_a '.

    view_a a county of 100 lines. Now, when I left outer join that discovers with a 'table_a', I expect all 100 lines.

    However, I'm more than 100 lines. Is it still possible?

    Also even to analyze these situations, how can I move forward?

    Because it is very high volumn of sight and takes longer to run.

    Select count (*) view_a, view_b

    where view_a.col1 = view_b.col1 (+)

    and view_a.col2 = view_b.col2 (+);

    Thank you

    I can see "view_a" and a table 'table_a '.

    view_a a county of 100 lines. Now, when I left outer join that discovers with a 'table_a', I expect all 100 lines.

    However, I'm more than 100 lines. Is it still possible?

    Also even to analyze these situations, how can I move forward?

    Because it is very high volumn of sight and takes longer to run.

    Select count (*) view_a, view_b

    where view_a.col1 = view_b.col1 (+)

    and view_a.col2 = view_b.col2 (+);

    Which is not necessarily related to the use of an outer join.

    Just join of two tables in general will give you more rows of one table has.

    Scott DEPT table contains ONE row for deptno = 10

    The EMP table has THREE rows of deptno = 10

    The number of rows you plan if you join two tables using an equi-join?

    Three - what is MORE lines the DEPT table has for deptno = 10

    Select * from Department where deptno = 10

    DEPTNO, DNAME, LOC
    10, ACCOUNTING, NEW YORK

    Select * from emp where deptno = 10

    MGR, EMPLOYMENT ENAME, EMPNO, HIREDATE, SAL, COMM, DEPTNO
    7782, CLARK, MANAGER, 7839, 6/9/1981,2450, 10
    7839, KING, PRESIDENT, 17 NOVEMBER 00, 10
    7934, MILLER, CLERK, 7782, 23 JANUARY 00: 10

    Select dept.*, emp.*
    Department, emp
    where dept.deptno = 10
    and dept.deptno = emp.deptno

    DEPTNO, DNAME, LOC, EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, COMM, DEPTNO_1
    10, ACCOUNTING, NEW YORK, 7782, CLARK, MANAGER, 7839, 6/9/1981,2450, 10
    10, ACCOUNTING, NEW YORK, 7839, KING, PRESIDENT, 17 NOVEMBER 00, 10
    10, ACCOUNTING, NEW YORK, 7934, MILLER, CLERK, 7782, 23 JANUARY 00: 10

    So if these are the lines ONLY in the table EMP and DEPT the query would give you THREE lines despite the DEPT table only ONE line.

    No do you expect? You get ALL the child rows that belong to the parent company. Otherwise, how could it possibly work?

    The OUTER join includes lines where the parent row exists but there is NO child line as others have shown.

    Outer joins

    Outer join extends the result of a simple join. Outer join returns all rows that satisfy the join condition and also returns some or all rows in a table for which no line of the other meet the join condition.

    Get more lines to exist in one of the paintings is a basic necessity. It usually has NOTHING to with the question of whether you have an outside to join or not.

    See the section on the JOINTS in the Oracle documentation

    http://docs.Oracle.com/CD/B28359_01/server.111/b28286/queries006.htm

  • What is the best way to optimize a SQL query: call a function or doing a join?

    Hi, I want to know what is the best way to optimize a SQL query, call a function inside the SELECT statement, or make a simple join?

    It depends on.  Could be a.  Could be the other.  Could be no difference.  You would need to compare with your tables in your environment with your settings.

    If you put a gun to my head, I was given no other information and required that I answered the question, I would tend to wait that the join would be more effective.  In general, if you can do something in pure SQL, it will be more effective than if you call PL/SQL.

    Justin

  • 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

  • Join OBIEE

    Hello
    I'm new to obiee and just trying to create a report by using a simple join. The join works fine if I use a MONTHNAME function, but if I try to use the other functions (month, quarter. year quarter, etc.) I get the error "Driver Odbc returned an error (SQLExecDirectW)." with OPR4ONWY:U9IM8TAC:OI2DL65P codes

    I don't know its just something simple escapes me, but if someone could point me in the right direction, it would be apreciated

    Just in case you are using the monthname function in the physical layer and trying to reach then it won't work.

    If you need to participate the same way then go to a join condition for the sake of the name, in the MDB layer create a logic using the function MonthName column and then create join foreign Kay. This join will override the physical layer of the join.

    If this isn't the case, then let me know ;)

    If it helps to appreciate if you score as correct

    Published by: Srini VIEREN on 10 January 2013 09:22

  • To only convert NOT EXISTS query JOIN plain

    Version: 10.2.0.5

    Developers have complained that the following query works very poorly and hooked most of the time.

    select distinct cust_id from cust_track_dtl TD
         where not exists 
         (select 1 from cust_master CM where TD.cust_id = CM.cust_id 
         and CM.rgn_code = TD.rgn_code
         CM.rgn_code = 'AP'
          )
    and TD.stat_code = 'C'
    and TD.proc_flag = 'Y'
    TD.rgn_code = 'AP'  ; ----------------> Is this logically correct ?
    CUST_TRACK_DTL table in the outer query has 2 million records
    
    CUST_MASTER table in their inner query(sub query) has 30 million records
    Currently, we are only at the design phase. I'm a bit confused about the
    rgn_code = 'AP'
    appearing in internal and external queries.

    I think that the motion seeks to recover all customers who are not the "AP" region, but the outer query WHERE clause has
    TD.rgn_code = 'AP'
    Is there something wrong with this logic?

    If it is logically correct, how can I convert this request with simple JOIN (ie. How can I get rid of NO thing EXISTS)?

    Your original. Rgn_code = "AP" is not necessary in the subquery but will change the results of the outer query.

    select distinct cust_id from cust_track_dtl TD
      left outer join cust_master CM
        on (TD.cust_id = CM.cust_iid AND
            CM.rgn_code = TD.rgn_code)
     WHERE TD.stat_code = 'C'
       and TD.proc_flag = 'Y'
       and TD.rgn_code = 'AP'
       and CM.cust_id IS NULL;
    

    or the other

    select pb.pub_name from publishers pb
      LEFT OUTER JOIN titles tt ON
        ON (tt.pubslisher_id = pb.publisher_id and
            tt.subject = 'RELIGION')
     where tt.pubslisher_id IS NULL;
    
  • Recordset advanced join works on test but not when I start page

    I created a simple join

    SELECT *.

    OF tenant_signup, name_editprop

    WHERE tenant_signup.prop_id = name_editprop.prop_id

    When I run the test, it shows the correct information. When I charger load in the page, then insert the relevant informaion it shows just the first record in the database

    any ideas would really help banging my head against a wall now

    Thanks in advance

    Right. As mentioned previously, you must include the user id in your SQL where clause.  First make a backup copy of the script above. Can change this:

    $query_Recordset1 = sprintf ("" SELECT * FROM tenant_signup WHERE userid = %s ", GetSQLValueString ($colname_Recordset1,"text")");

    to do this:

    $query_Recordset1 = sprintf ("" SELECT * FROM tenant_signup, name_editprop WHERE the name_editprop.prop_id = tenant_signup.prop_id AND userid = %s ", GetSQLValueString ($colname_Recordset,"text")");

  • Joining tables plus with php and sql

    Hello

    I am familiar with the join of two tables, but recently need to join the three tables and find hard to do.


    This is my code:

    $sqlconnect = mysql_query ("SELECT Friends.frinum, Friends.userid, Friends.friendid, Experiences.expid, Experiences.userid, Experiences.title, Experiences.Dateofexpi, Experiences.description, Experiences.datetime
    OF experiences INNER JOIN friends on Friends.userid = Friends.friendid
    UNION

    SELECT Users.id, Users.username, Users.profilepic, Friends.frinum, Friends.friendid, Friends.userid OF friends INNER JOIN users on Friends.userid is '$id' ");

    I tried the Union to incorparate I'm not familiar with and experience problems when you try results.

    The three tables are users, experiences and friends.

    If anyone can help.

    The selection list of all requests in a Trade Union must have matching data types. Your union query is not valid because your fields do not match. Why do you think that you need a Union? A simple join is probably all you need.

  • Bug in outer join syntax?

    I use Oracle 10.2, and I think I found a bug in what is allowed for the outer join syntax. Specifically, I am allowed to specify "outer join" without specifying if it's left, right, or full outer join. It behaves as an inner join.

    The documents show that the type_de_jointure is optional, but does not allow the 'outside' keyword be used alone: http://download.oracle.com/docs/cd/A97630_01/server.920/a96540/statements_103a.htm#2126207

    Small example:
    create table TABLE_A (ID number(10) primary key, VALUE_A varchar2(50));
    create table TABLE_B (ID number(10) primary key, VALUE_B varchar2(50));
    insert into TABLE_A (ID, VALUE_A) values (1, 'abc');
    insert into TABLE_A (ID, VALUE_A) values (2, 'def');
    insert into TABLE_A (ID, VALUE_A) values (3, 'ghi');
    insert into TABLE_B (ID, VALUE_B) values (2, 'jkl');
    insert into TABLE_B (ID, VALUE_B) values (3, 'mno');
    insert into TABLE_B (ID, VALUE_B) values (4, 'pqr');
    commit;
    select ID, VALUE_A from TABLE_A;
    select ID, VALUE_B from TABLE_B;
    select ID, VALUE_A, VALUE_B from TABLE_A join TABLE_B using (ID);
    select ID, VALUE_A, VALUE_B from TABLE_A full outer join TABLE_B using (ID);
    select ID, VALUE_A, VALUE_B from TABLE_A outer join TABLE_B using (ID);
    The release of the last three selects shows that the OUTER JOIN behaves as a simple JOIN, rather than return a syntax error or at least behave like a FULL OUTER JOIN (this is where the absence of a syntax error is misleading):
    SQL> select ID, VALUE_A, VALUE_B from TABLE_A join TABLE_B using (ID);
    
            ID VALUE_A                                            VALUE_B
    ---------- -------------------------------------------------- --------------------------------------------------
             2 def                                                jkl
             3 ghi                                                mno
    
    SQL> select ID, VALUE_A, VALUE_B from TABLE_A full outer join TABLE_B using (ID);
    
            ID VALUE_A                                            VALUE_B
    ---------- -------------------------------------------------- --------------------------------------------------
             1 abc
             2 def                                                jkl
             3 ghi                                                mno
             4                                                    pqr
    
    SQL> select ID, VALUE_A, VALUE_B from TABLE_A outer join TABLE_B using (ID);
    
            ID VALUE_A                                            VALUE_B
    ---------- -------------------------------------------------- --------------------------------------------------
             2 def                                                jkl
             3 ghi                                                mno
    
    SQL> 
    Y at - there somewhere that I can tell you that?

    If you have a supported Oracle agreement you can save a Service request with Oracle, but they can answer that this is not a bug. The problem is that the 'outside' keyword in your 3rd example is treated as an alias for TABLE_A because it is not considered as a reserved keyword.

    with table_a as (
    select 1 as id, 'abc' as value_a from dual union all
    select 2 as id, 'def' as value_a from dual union all
    select 3 as id, 'ghi' as value_a from dual
    
    )
    , table_b as (
    select 2 as id, 'jkl' as value_b from dual union all
    select 3 as id, 'mno' as value_b from dual union all
    select 4 as id, 'pqr' as value_b from dual
    )
    select ID, outer.VALUE_A, VALUE_B from TABLE_A outer join TABLE_B using (ID);
    
    ID                     VALUE_A VALUE_B
    ---------------------- ------- -------
    2                      def     jkl
    3                      ghi     mno
    

    If you query the view RESERVED_WORDS of V$ it will tell you what keywords are reserved.

    select * from V$RESERVED_WORDS where keyword in ('OUTER', 'SELECT','USING');
    
    KEYWORD                        LENGTH                 RESERVED RES_TYPE RES_ATTR RES_SEMI DUPLICATE
    ------------------------------ ---------------------- -------- -------- -------- -------- ---------
    USING                          5                      N        N        N        N        N
    OUTER                          5                      N        N        N        N        N
    SELECT                         6                      Y        N        N        N        N
    

    You'll get a similar result, if you tried

    select ID, VALUE_A, VALUE_B from TABLE_A using join TABLE_B using (ID);
    

    Kind regards
    Bob

  • View materialized with joins

    Dear Dev/DBA,

    I have the following scenario:

    SQL > CREATE TABLE T1 (ID NUMBER (3), NAME VARCHAR2 (10));
    SQL > CREATE TABLE T2 (identification NUMBER (3), NAME VARCHAR2 (10));

    T1 contains records with the number ID of 10 to 80 and the T2 having the ID of 90 to 170

    SQL > SELECT * FROM T1 JOIN SELECT ALL * T2
    It gives all the records in the 2 tables.

    I intend to create a materialized view (like CREATE MATERIALIZED VIEW V_TAB REFRESH ON COMMETTRE AS SELECT * T1 JOIN ALL SELECT * FROM T2) and it seems that I can't do with the error ORA-12054, also said oracle documentation that materialized view can only be used with a simple join.

    Do you have another solution?
    Note that materialized views can be used to improve the queries.

    Thanks in advance

    In addition VIEWS are not used in case you should query the tables attached, having a lot of records.

    I have no idea what you mean here, but as you yourself pointed out you not join. You use a UNION all.

    The materialized view is a database object that contains the data (and not only a SELECT query), and it is used to improve the speed of queries.

    Thanks for the lesson, but it seems that materialized views do not work in your case.

  • Always parallel hash join paginate in TEMP

    Hello

    I've known some strange behaviors on Oracle 9.2.0.5 recently: hash query simple join of two tables - smaller with 16 k records/1 MB in size and more important with 2.5 m records/1.5 GB in size is trading at TEMP at the launch in parallel mode (4 game PQ slaves). What is strange performance series runs as expected - in memory occurs hash join. It should be added that running parallel and series correctly selects smaller table as an intern but parallel query always decides to buffering data source (no matter what is its size).

    To be more precise - all the table statistics gathered, I have enough memory PGA assigned to queries (WORKAREA_POLICY_SIZE = AUTO, PGA_AGGREGATE_TARGET = 6 GB) and I analyze the results. Same hidden parameter px_max_size MMSis set correctly to about 2 GB, the problem is that parallel execution still decides to Exchange (even if the internal size of data for each slave is about 220 KB.).

    I dig in the footsteps (event 10104) and found a substantial difference between series and parallel execution. It seems that some internal indicator order PQ slaves to the buffer always data, here's what I found in trace slave PQ:

    HASH JOIN STATISTICS (INITIALIZATION)
    Original brief: 4428800
    Memory after all overhead costs: 4283220
    Memory for the slot machines: 3809280
    Calculated overhead for partitions and slot machine/line managers: 473940
    Fan-out hash join: 8
    Number of sheets: 9
    Number of slots: 15
    Diluvium IO: 31
    Block size: 8
    Cluster size (slot): 248
    Join hash fanout (manual): 8
    Cluster/slot size (manual): 280
    Minimum number of bytes per block: 8160
    Bit memory allocation (KB) vector: 128
    By partition bit vector length (KB): 16
    Possible maximum line length: 1455
    Size (KB) of construction found: 645
    Estimates the length of the line (including overhead): 167
    Immutable flags:
    The result of the join of the BUFFER for a parallel query
    kxhfSetPhase: phase = BUILD
    kxhfAddChunk: Add 0 (sz = 32) piece to the table slot machine
    kxhfAddChunk: chunk 0 (lb = 800003ff640ebb50, slotTab = 800003ff640ebce8) successfully added
    kxhfSetPhase: phase = PROBE_1

    In bold is the part that is not present in serial mode. Unfortunately that I can't find something that could help identify the reason or the definition that drives this behavior :(

    Best regards
    Bazyli

    Published by: user10419027 on October 13, 2008 03:53

    Buzzylee wrote:
    Jonathan,
    >
    After the trials of today that my understanding of the problem has not significantly changed - I still don't understand why Oracle swaps table of probe on the disc.
    The only new, is that I see it's not typical hash join of "on the disk", because the inner table is not written to TEMP. More you confirmed this immutable flag is not forcing this kind of behavior (BTW, thanks for that!).

    So maybe that's the bug? In the meantime, I checked it against never version of DB (9.2.0.8) - always the same behavior.

    I copied your example - the behavior also appears in 10g and 11g.
    This probably isn't a bug, but it may be a case where a generic strategy is not appropriate.

    The extra partition does NOT probe table, now is the result of the hash join. The result is built until this draft is sent to the next 'series of slave' (who is being the Coordinator of the application in this case). Your allocation of memory allowed for about 18 slots (diluvium IO lots) of 31 blocks each. You used 8 of them for the hash table, the rest is available to hold the result.

    Somewhere in your path, around the point where you go from scripture readings, you should see a summary on the partition 8 and set the number of "memory seats" that will tell you the size of the result.

    If the difference between the clusters and the slots in the memory is low, you can see that by setting the '_hash_multiblock_io_count' to a value less than 31 than the selected optimizer free you enough memory for the hash table for the result set to build in memory.

    Another option - to circumvent this spill - is to switch to a (broadcast, none) distribution.

    Concerning
    Jonathan Lewis
    http://jonathanlewis.WordPress.com
    http://www.jlcomp.demon.co.UK

  • Last Email sent

    Hi, I was looking for assistance regarding the drafting of a request for help me to find the last email sent to a particular address for each job ID. I created some examples of paintings of the nature of the data, so I was hoping someone could help me.

    My create queries to tables

    CREATE TABLE "BAS_MAIL_1" 
       ( "ID" NUMBER(10,0), 
     "SENT" DATE, 
     "SENDER" VARCHAR2(512 BYTE), 
     "TO_" VARCHAR2(512 BYTE), 
     "CC" VARCHAR2(512 BYTE)
       )
    
    CREATE TABLE "BAS_MAIL_2" 
       ( "ID" NUMBER(10,0), 
     "MID" NUMBER(10,0), 
     "JOB_NO" VARCHAR2(256 BYTE), 
     "USERID" NUMBER(10,0), 
     "TDATE" DATE
       )
    

    INSERT orders

    Insert into BAS_MAIL_1 (ID,SENT,SENDER,TO_,CC) values (345242,to_date('22-MAY-15 03:13:32','DD-MON-RR HH24:MI:SS'),'[email protected]','[email protected]',null);
    Insert into BAS_MAIL_1 (ID,SENT,SENDER,TO_,CC) values (345255,to_date('22-MAY-15 03:16:35','DD-MON-RR HH24:MI:SS'),'[email protected]','[email protected]',null);
    Insert into BAS_MAIL_1 (ID,SENT,SENDER,TO_,CC) values (346078,to_date('23-MAY-15 01:37:41','DD-MON-RR HH24:MI:SS'),'[email protected]','[email protected]; [email protected]',null);
    Insert into BAS_MAIL_1 (ID,SENT,SENDER,TO_,CC) values (346084,to_date('23-MAY-15 01:55:59','DD-MON-RR HH24:MI:SS'),'[email protected]','[email protected]',null);
    
    Insert into BAS_MAIL_2 (ID,MID,JOB_NO,USERID,TDATE) values (350366,345242,'1183068',123456789,to_date('22-MAY-15 15:14:20','DD-MON-RR HH24:MI:SS'));
    Insert into BAS_MAIL_2 (ID,MID,JOB_NO,USERID,TDATE) values (350418,345255,'1183068',123456789,to_date('22-MAY-15 15:17:23','DD-MON-RR HH24:MI:SS'));
    Insert into BAS_MAIL_2 (ID,MID,JOB_NO,USERID,TDATE) values (351199,346078,'1183068',123456789,to_date('23-MAY-15 13:38:20','DD-MON-RR HH24:MI:SS'));
    Insert into BAS_MAIL_2 (ID,MID,JOB_NO,USERID,TDATE) values (351205,346084,'1183068',123456789,to_date('23-MAY-15 13:56:20','DD-MON-RR HH24:MI:SS'));
    

    The sample tables I built only currently exist for job no. 1, but I want to assure you that this works for all of the jobs that I have in my paintings and also the 'TO' field must have an address @ @Hotmail.com or @gmail.com-other than the line must be rejected. If more than one email is shown I have to make sure that it is divided into different columns: Email_1, Email_2 etc.

    I managed to write a simple join me showing the data of the entire table.

    SELECT
        *
    FROM 
        BAS_MAIL_2 T
    JOIN
        BAS_MAIL_1 B
    ON
        T.MID = B.ID
    WHERE
        JOB_NO = '1183068'
    ORDER BY
        T.TDATE
        ;
    

    So this shows how the tables are linked together, but the output I need is the following:

    JOB_NO, SENT, SENDER, EMAIL_1, EMAIL_2, EMAIL_3
    1183068, 23-MAY-15 01:37:41, [email protected], [email protected], [email protected], null
    

    I hope that all makes sense.

    Thanks in advance.

    Hello

    If you're stuck with the design of the table, here's a way to do what you asked:

    WITH got_r_num AS

    (

    SELECT b1.sent, b1.sender, b1.to_

    b2.job_no

    Rank () OVER (PARTITION BY b2.job_no

    ORDER BY b1.sent DESC

    )                       AS r_num

    , INSTR (b1.to_ |) (',';', 1, 1) AS pos_1

    , INSTR (b1.to_ |) (',';', 1, 2), pos_2

    , INSTR (b1.to_ |) (',';', 1, 3) AS pos_3

    Bas_mail_1 B1

    JOIN bas_mail_2 ON b2.mid = b1.id b2

    WHERE the b1.to_ | ';'  AS ' %@gmail.com; »

    OR b1.to_ | ';'  AS ' %@hotmail.com; »

    )

    SELECT job_no

    sent

    the sender

    , SUBSTR (to_, 1, pos_1 - 1) AS email_1

    SUBSTR (to_, pos_1 + 1, pos_2 - (pos_1 + 1)) AS email_2

    SUBSTR (to_, pos_2 + 1, pos_3 - (pos_2 + 1)) AS email_3

    OF got_r_num

    WHERE r_num = 1

    ;

    The number of columns must be hard-coded in any question.  Above, I've hardcoded email 3 columns; You can easily make this any number desired.  If the chosen to_ list contains not only a lot of addresses, the query still works; the emails will simply be NULL.

    If your actual data have several job_nos, the sample data should not have at least 2?

    If performance is not a problem, then you can consider using REGEXP_SUBSTR to get the ;-delimited parts of early in the main query.  In this case, you won't need derive pos_ columns in the subquery.

  • problem with ioining several anchor points

    How can I more simple join a cloud of anchors to a path?

    I tried a few options of access road and joins, but none has managed to reach individual anchor points...

    Please help!

    See you soon

    These are all segments of open path?

    In this case try the 'Join reasonably' script of mustapha page: Scripts for Adobe Illustrator CS

    But you must select the same paths before applying the script via Select > same or the magic wand tool

Maybe you are looking for