Comparing the same outer join column.

Hello

I have the following query.
SELECT Replens.Date1               AS date1,
  Replens.USER_ID                  AS Operator1,
  Picks.USER_ID                    AS Operator1,
  Users.Time                       AS Logged_in_hours,
  Replens.Quantity                 AS Pallet_replened,
  SUM(Replens.Quantity/Users.Time) AS Replen_rate,
  Picks.Quantity                   AS Cases_picked,
  SUM(Picks.Quantity/Users.Time)   AS Pick_rate
FROM
  (SELECT libclientreports.getshift(itl.dstamp) Date1,
    ITL.USER_ID,
    COUNT(ITL.tag_id) Quantity
  FROM INVENTORY_TRANSACTION ITL
  WHERE ITL.code                                     = 'Replenish'
  AND TO_CHAR(itl.dstamp, 'DD-Mon-YYYY HH24:MI:SS') >= '01-Mar-2010 06:00:00'
  AND TO_CHAR(itl.dstamp, 'DD-Mon-YYYY HH24:MI:SS') <= '01-Mar-2010 18:00:00'
  GROUP BY libclientreports.getshift(itl.dstamp),
    ITL.USER_ID
  ORDER BY ITL.USER_ID,
    libclientreports.getshift(itl.dstamp)
  ) Replens,
  (SELECT libclientreports.getshift(itl.dstamp) Date1,
    ITL.USER_ID,
    SUM(ITL.update_qty) Quantity
  FROM INVENTORY_TRANSACTION ITL
  WHERE ITL.to_loc_id                                = 'CONTAINER'
  AND TO_CHAR(itl.dstamp, 'DD-Mon-YYYY HH24:MI:SS') >= '01-Mar-2010 06:00:00'
  AND TO_CHAR(itl.dstamp, 'DD-Mon-YYYY HH24:MI:SS') <= '01-Mar-2010 18:00:00'
  GROUP BY libclientreports.getshift(itl.dstamp),
    ITL.USER_ID
  ORDER BY ITL.USER_ID,
    libclientreports.getshift(itl.dstamp)
  ) Picks,
  (SELECT USER_ID,
    SUM(LibClientReports.getLoggedInHours (USER_ID, to_date('01-Mar-2010 06:00:00', 'DD-Mon-YYYY HH24:MI:SS'), to_date('01-Mar-2010 18:00:00', 'DD-Mon-YYYY HH24:MI:SS')) )/60 TIME
  FROM APPLICATION_USER
  GROUP BY USER_ID
  ) Users
WHERE Users.Time != '0'
AND Users.USER_ID = Picks.USER_ID (+)
AND Users.USER_ID = Replens.USER_ID (+)
GROUP BY Replens.Date1,
  Replens.USER_ID,
  Picks.USER_ID,
  Users.Time,
  Picks.Quantity,
  Replens.Quantity
ORDER BY Replens.USER_ID,
  Replens.Date1
The problem I have is with the operator1 columns, I've done outer joins on the Users table that contains all users that will be returned in the tables of the peaks and Replens.
However, I want to merge this operator1 into one column. For example, here is the current data, I have for the two columns of the operator 1;
Operator1       Operator1_1

D9AGY19             D9AGY19
D9BEELB             D9BEELB
D9FULOPS     (null)
D9GAWKOWA     D9GAWKOWA
D9LIDDING     D9LIDDING
D9NOWAKS     D9NOWAKS
(null)             D9AGY10
(null)             D9AGY13
(null)             D9AGY15
(null)             D9AGY17
And here is the data I want to see;
Operator1

D9AGY19
D9BEELB
D9FULOPS
D9GAWKOWA
D9LIDDING
D9NOWAKS
D9AGY10
D9AGY13
D9AGY15
D9AGY17
Notice the USER_ID to replace the values (null).

Could someone please explain to me how to make this happen? If you want more information please let me know.


Kind regards

SM.

This should do if Op1 and Op1_1 are always the same or one or the other is null. If both are filled and have different values, then it will not work:

nvl(Replens.USER_ID, Picks.User_ID) as                  AS Operator1

Tags: Database

Similar Questions

  • How to export data to excel that has 2 tables with the same number of columns and the column names?

    Hi everyone, yet once landed upward with a problem.

    After trying many things to myself, finally decided to post here...

    I created a form in form builder 6i in which clicking on a button, the data gets exported to the excel sheet.

    It works very well with a single table. The problem now is that I cannot do the same with 2 tables.

    Because the tables have the same number of columns and the columns names.

    Here are the 2 tables with column names:

    Table-1 (MONTHLY_PART_1) Table-2 (MONTHLY_PART_2)
    SL_NOSL_NO
    MODELMODEL
    END_DATEEND_DATE
    U-1U-1
    U-2U-2
    U-4U-4
    ..................
    ..................
    U-20U-20
    U-25U-25

    Given that the tables have the same column names, I get the following error :

    402 error at line 103, column 4

    required aliases in the SELECT list of the slider to avoid duplicate column names.

    So how to export data to excel that has 2 tables with the same number of columns and the column names?

    Should I paste the code? Should I publish this query in 'SQL and PL/SQL ' Forum?

    Help me with this please.

    Thank you.

    Wait a second... is this a kind of House of partitioning? Shouldn't it is a union of two tables instead a join?

    see you soon

  • Get the error invalid identifier in the left outer join

    I wrote a query and get the invalid identifier error during execution:
    the exact error is: ORA-00904: "D". "" ACCT_NO ": invalid identifier
    This query is not able to access the parent table alias in the subquery of the left outer join.

    This is the query:
    SELECT D.PROD_DESC_TX, BASE. ASSET_NUM, BASE. PROD_ID, BASE.NAME
    OF TABLE1 D
    LEFT OUTER JOIN
    (
    SELECT ASSET_NUM, PROD_ID, B.SID
    FROM TABLE2 E
    JOIN IN-HOUSE TABLE3 HAS IT E.PROD_ID = A.ROW_ID
    JOIN INTERNAL TABLE 4 C ON A.PAR_PROD_INT_ID = C.ROW_ID
    INTERNAL TABLE5 JOIN B ON C.ROW_ID = B.PAR_ROW_ID
    AND B.TYPE = 'VALUE '.
    AND B.NAME = 'VALUE '.
    WHERE E.ASSET_NUM = ((CASE WHEN LTRIM (RTRIM (D.BANK_NO)) = '021 ' THEN '021' ELSE ' 020' END) |) LTRIM (RTRIM (D.APPL_CD)). LTRIM (RTRIM (D.ACCT_NO)))
    ) BASE ON ((CASE WHEN LTRIM (RTRIM (D.BANK_NO)) = '021 ' THEN '021' ELSE ' 020' END) |) LTRIM (RTRIM (D.APPL_CD)). LTRIM (RTRIM (D.ACCT_NO))) = BASE. ASSET_NUM
    WHERE D.BANK_NO = 'VALUE '.
    AND D.APPL_CD = 'VALUE '.
    AND D.ACCT_NO = 'VALUE '.

    Edited by: user648525 13 Sep, 2011 01:21

    I can easily look at your request at this time (using my iPhone on a train).

    But trying out this line in the WHERE (the one with the invalid reference) clause in the main query.

    Who is... in the view of inline, use only the logic of the join (the clauses).

    Overflow the filtering logic (WHERE clause) to the main request. You may need to select some additional inline view columns to make these references work.

  • How to select data using the same remote database column name 3

    Hello


    Can anyone help me on how to get the data with the same remote database column names 3 and a unique nickname.

    E.g.

    SELECT *.
    B.SID, b.status, SUM (b.qty) qantity MAX (b.) date_as_of
    Of
    * ((table1@remotedatabase1, table1@remotedatabase2, table1@remotedatabase3) has, *)
    (* (table1@remotedatabase1, table1@remotedatabase2, table1@remotedatabase3) b). *
    WHERE b.dept = 'finance '.
    AND a.position = "admin".
    AND a.latest = 'Y' AND (b.status <>"MLT") AND b.qty > 0;
    B.SID GROUP, b.status;

    NOTE: the instructions "BOLD" is just an example of what I want to do but I always get an error beacause of ambiguous column.

    Thanks to advnce. :)

    Published by: user12994685 on 4 January 2011 21:42

    user12994685 wrote:

    Can anyone help me on how to get the data with the same remote database column names 3 and a unique nickname.

    Not valid. This makes no sense and breaks all the rules of scope-resolution. And if it is in a single database, or uses tables in databases, is not relevant.

    Each object must be particularly well identified. If you cannot do this:

    select * from (table1@remotedatabase1, table1@remotedatabase2, table1@remotedatabase3) a
    

    3 objects cannot share the same alias. Example:

    SQL> select * from (dual, dual) d;
    select * from (dual, dual) d
                       *
    ERROR at line 1:
    ORA-00907: missing right parenthesis
    

    You need to combine objects - by using a join union or similar. He will have to be done as follows:

    SQL> select * from (select * from dual d1, dual d2) d;
    select * from (select * from dual d1, dual d2) d
           *
    ERROR at line 1:
    ORA-00918: column ambiguously defined
    

    However, we need to have unique column in a projection of SQL names - so the join of the need to project a unique set of columns. So:

    SQL> select * from (select d1.dummy as dummy1, d2.dummy as dummy2 from dual d1, dual d2) d;
    
    DUM DUM
    --- ---
    X   X
    
    SQL> 
    

    I suggest that you look carefully at what opportunities are and how it applies in SQL - and ignore if the referenced objects are local or remote, because it has no effect on the basic principles of scope-resolution.

  • He had to know the right outer join using...

    He had to know the right outer join using...

    For example: first query left outer join for the emp table: SELECT EMPNO, ENAME, D.DEPTNO FROM EMP E, Department D WHERE the E.DEPTNO = D.DEPTNO)

    Second query left outer join for the Dept table: SELECT EMPNO, ENAME, D.DEPTNO FROM EMP E, Department D WHERE the D.DEPTNO = E.DEPTNO)

    In the example above I just Exchange where condition condition to get an outer join of two table with a left outer join itself. Wat is use right outer join, instead, I can swap the status of table name for the result. Please suggest...

    Hello

    chan001 wrote:

    He had to know the right outer join using...

    For example: first query left outer join for the emp table: SELECT EMPNO, ENAME, D.DEPTNO FROM EMP E, Department D WHERE the E.DEPTNO = D.DEPTNO)

    Second query left outer join for the Dept table: SELECT EMPNO, ENAME, D.DEPTNO FROM EMP E, Department D WHERE the D.DEPTNO = E.DEPTNO)

    In the example above I just Exchange where condition condition to get an outer join of two table with a left outer join itself. Wat is use right outer join, instead, I can swap the status of table name for the result. Please suggest...

    The two examples above use the old syntax outer join of Oracle. (I guess there should be a sign inside the parentheses, e.g.. +)

    ...  WHERE E.DEPTNO = D.DEPTNO (+)

    )

    The LEFT OUTER JOIN and RIGHT OUTER JOIN terms apply only to the ANSI join syntax, e. g.

    .

    .. FROM EMP E

    DEPT LEFT OUTER JOIN D ON E.DEPTNO = D.DEPTNO

    As Blushadow said above, there's no real point in having LEFT OUTER JOIN and RIGHT OUTER JOIN;  What you can do with one (or a combination of both) can be done with the other.  Most people use LEFT OUTER JOIN systematically and never use RIGHT OUTER JOIN.

    There are situations where using a combination of the two would mean a little less striking, but only a little less and this kind of situation is very common, and one may wonder if the somewhat shorter code is more specific.  I suggest that forget you RIGHT OUTER JOIN.

  • CF8 cfquery multiple table join with the same names of columns - default

    This seems to be a defect in the CF8 cfquery object. I'm at a loss as to a solution or a good work around. With regard to the substance, this query is generated dynamically on the fly based on what is happening in it a user. This isn't the most elegent SQL but work and return all columns. The app itself is a data viewer to look at the logs. Here is an example of a query being generated.

    Select *.

    of web_trans, web_info_trans, web_res_trans

    where (web_info_trans.trans_dte > = '' 2008-12-1)

    and web_info_trans.trans_dte < '' 2008-12-2)

    and (web_info_trans.trans_dte = web_trans.trans_dte)

    and (web_info_trans.trans_num = 5060345)

    and (web_info_trans.trans_num = web_trans.trans_num)

    and (web_res_trans.trans_num = 5060345)

    and (web_res_trans.trans_num = web_trans.trans_num)

    and (web_trans.web_trans_cde = "NTUI")

    and (web_trans.web_status_cde = 'P')

    and (web_trans. TRANS_NUM < 5060347)

    order of web_trans. TRANS_NUM / / desc

    These three tables contain a similar column called ZIP_CDE. They contain different values, and when this query is executed in Microsoft Query Analyzer results are displayed correctly. Run this same query SQL with CFQUERY and the value of one of the other tables (web_trans) will eventually replace the value for the other columns called ZIP_CDE. The exact amount columns are retruned only values some how get corrupted.

    This is a defect of cf8 is a book autour or an update that resolves this problem that I may have missed?

    Thank you for the ideas.

    Thus it seems still as a default since CF is essentially where, except for the return value play. Other query tools return results correctly so for me, it turns out be CF bug at a certain level.

    Actually I'm swinging to agree with you here, but not for the same reason.  CF actually * is * get all the columns back (as you say), it just doesn't expose a way to tell the difference between a column called 'x' and an another column called 'x', because the way to access the data in columns is simple queryname [columnName] [rowNumber] (or a Variant fo this, but all the amount of variations to that or abbrev. it).  This code shows how he has all four columns of the original two queries (being a stand-in for tables, in this case):


    Q1 = queryNew("");
    Q2 = queryNew("");
       
    queryAddColumn (q1, 'id', [1,2,3,4]);
    queryAddColumn (q1, "data", ["one", "two", "three", "four"]);
    queryAddColumn (q2, 'id', [1,2,3,4]);
    queryAddColumn (q2, "data", ["tahi", "rua", "toru", "wha"]); It's Maori, in case you are interested


    SELECT *.
    Q1, q2
    WHERE q1.id = q2.id

    So CF knows there are four columns (a call getMetadata (q3) get also demonstrates this), but it does not expose a way to approach the second (or even greater) column of the same name.  This is the bug/shortfall.

    However, relying on an underlying coldfusion.sql.QueryTable method, you can rename the columns, so:

    Then you're OK.

    I would be normally reluctant to recommend doing this, because these methods change from version to version of CF, but it's your call whether this approach will help you.

    To be honest, I'm with Owain who, even in SQL one generally doesn't work with columns with the same name, an alias them qualified with a table name/alias. As the table columns from of is not returned by SQL with the result set, it must be evidence against this by folding the columns in the first place.

    Also, I wonder at the bottom of the extraction of data, you don't really know the structure, that is to say, do SELECT *.  How can you know not even that is ours as the first column, second column, etc.?  I don't think that SQL applies in fact a contract that, t - it?  (I don't know).

    What are you actually do here?

    --

    Adam

  • Compare the same value of the column

    Hello
    I have table as below
    ID      Date     Department
    1   25-Jul-08        XX
    2   26-Jul-08        XX
    3   22-May-08        YY
    4   23-May-08        YY
    5   24-May-08        YY
    6   13-Jun-08        ZZ
    7   14-Jun-08        ZZ
    Now, I need to compare the date of each Department and return the case to higher-value Date only in this Department. my result set must therefore as below:
    ID      Date     Department
    2   26-Jul-08        XX   
    5   24-May-08        YY
    7   14-Jun-08        ZZ
    any idea?

    Is only one record in the Department with the highest date?
    If so, use aggregate KEEP statement:

    SELECT max (id) to Dungeon code (dense_rank of first order of date # desc).
    Max(date#), Department of
    Of

    Group of Department;

    If several whan a line with the date of the highest can exist in a single Department, use

    SELECT id, date #, Department
    de)
    SELECT id, date #, Department, dense_rank() on Dr. (depatyment date order partition # desc)
    Of


    )
    where dr = 1

    (Not tested!)

    Rgds.

  • Modeling of the left outer join

    Hello world

    I'm tender hand to you guys for a modeling help

    I have a FACT, the customers, the Dim_Date and CUST_ADDRESS of tables to model

    Fact and the client are joined through CUST_ID

    FACT and DATE are joined through DATE_ID

    CUST_ADDRESS must be attached to the top of the model through CUST_ID, DATE_ID and this join must be Left outer because sometimes the address does not exist or is not current, which means DATE_ID could be different between Dim_Date and CUST_ADDRESS

    If it were to join internal, model would have been easy, because of the outside left that I am unable to model, it's pretty good.

    Application under
    Select D.DATE, C.CUST_NAME, CA. ADDRESS, F.AMOUNT
    Of
    F FACT
    JOIN THE
    CUSTOMER C
    ON C.CUST_ID = F.CUST_ID
    JOIN THE
    DIM_DATE D
    ON F.DATE_ID = D.DATE_ID
    LEFT OUTER JOIN
    CUST_ADDRESS CA
    ON C.CUST_ID = CA. CUST_ID AND C.DATE_ID = D.DATE_ID

    Thanks in advance

    When I add the CUSTOMER and in FACT LTS CUST_ADDRESS

    Stop it!

    Don't add CUSTOMER and CUST_ADDRESS in the FACT of LTS. Why would add you to the LTS DO?

    You design a management model: CUSTOMER is a dimension and it has its own logical table this logic table join with a logical join in the activity diagram. Ditto for CUST_ADDRESS.

    So the change, I missed earlier is CUST_ADDRESS contains no Cust_ID (ACTUALLY existing), but contains a Cust_NO, and the table to translate Cust_NO in Cust_ID is CUSTOMER?

    No problem...

    Let's start with a new alias of CUSTOMER (to keep more simple to understand at the moment), call as you want, but this new alias will be the link between the FACT and CUST_ADDRESS.

    In LTS of the dimension 'Address', you have CUST_ADDRESS initially, add an inner join on the new alias that you created in the LTS of the CUSTOMER. So now your 'Address' logical dimension contains the Cust_NO and Cust_ID and this will make the join to FACT.

    Between CUST_ADDRESS and the CLIENT, you can keep an inner join, because the target is not not for get the address of the customer, but is having the Cust_ID in the address line.

    Give it a try at that.

    But do not add these tables in the LTS, they are logical dimensions.

  • Use the same image twice column in a report

    Hello

    I have a question which is, I can use the same column (column A in the example) picture twice in a report? first occurrence (column A) will show the thumbnail of the image and the second occurrence (column A) will display the image download link that opens the picture in a new window. Is this possible?

    Thank you

    Alexander

    -APEX-perf wrote:

    Yes, it is possible. However, if you intend to have two different images, then I would suggest you use javascript to link or download the blob.

    What's happening on Earth? Why JavaScript is necessary to download two different images? Even if he was in any real way, the OP is clear that the link posted of thumbnails and download involves the same image.

    To accomplish this task, you use decode or create a union query.

    No, all that should be necessary is the image column twice in the projection of the reference report query and apply a mask download format to a column and one mask of the image to the other. That the OP apparently did not this probably indicates that they are unnecessarily complicate things.

    For example:

    Select '' link_col

    table

    where allow_view = 'Y '.

    Union of all the

    Select '' link_col

    table

    where allow_view = ' don't

    or

    Select decode (allow_view, 'Y',

    '',

    ("") link_col

    table

    What is downloadImg? It is not a Standard API JavaScript APEX. Therefore, it is highly unlikely that this is of no use to the op.

  • Comparing the same tables of two schemas

    I had already posted a similair on this thread. So, I thought I would start a new thread on this to avoid confusion

    I want to generate a report that shows the difference in the data type of the columns in the same table in two different patterns.

    The query using LESS shows the difference below.

    create table SCOTT.mytab1 (empid number);
    create table HR.mytab1 (empid varchar2(34));
    
    
    SELECT   table_name, column_name, OWNER schema, data_type
    FROM     dba_tab_cols where owner = 'SCOTT'
    AND TABLE_NAME = 'MYTAB1'
    MINUS
    SELECT   table_name, column_name, OWNER schema, data_type
    FROM     dba_tab_cols where owner = 'HR'
    AND TABLE_NAME = 'MYTAB1'
    
    Result:
    TABLE_NAME      COLUMN_NAME     SCHEMA     DATA_TYPE
    --------------- --------------- ---------- ------------
    MYTAB1          EMPID           SCOTT      NUMBER
    But, since it is a report, I want to see the form of results the two schemas that has column of different data types with the same names of table

    Expected results:
    TABLE_NAME      COLUMN_NAME     SCHEMA     DATA_TYPE
    --------------- --------------- ---------- ------------
    MYTAB1          EMPID           SCOTT      NUMBER
    MYTAB1          EMPID           HR         VARCHAR2
    Anyway I could do this?

    Why not get a single line with two types of data:

    select a.table_name, a.column_name, a.data_type schema1_type, b.data_type schema2_type
    from all_tab_columns a, all_tab_columns b
    where a.owner = 'SCOTT'
    and b.owner = 'HR'
    and a.table_name=b.table_name
    and a.column_name=b.column_name
    and a.data_type!=b.data_type;
    

    This extracted single query columns present on the two schemas but with different data types. These columns only on one of the two schemas are not extracted.

    Max

  • Full table on the right outer join scan

    Hello, I need help. Here's my query-

    SELECT / * + first_rows (100) * /.
    a.custom_gr_id, a.custom_gr_name AS customgroupname,
    a.custom_gr_type_id AS customtypeid, b.workspace_id, b.NAME, a.itime,
    a.is_shared_org AS est_partagee
    OF custom_group_pa one
    RIGHT OUTER JOIN
    account_workspace_pa b ON (a.workspace_id = b.workspace_id
    AND (a.delete_flag IS NULL or a.delete_flag <>1)
    AND a.owner_id = '123')
    WHERE b.workspace_id <>- 9999
    AND b.workspace_type_id = 1
    AND b.delete_flag = 0
    AND EXISTS (SELECT 1
    Of account_workspace_type c
    WHERE b.workspace_type_id = c.workspace_type_id)
    ITime to ORDER BY DESC;

    Account_workspace_pa almost 1 500 483 lines and custom_group_pa had 200 000 lines and account_workspace_type is a very small table of 10 lines.

    I always get a full on table account_workspace_pa table scan, while I have clues about workspace_id AND I index on workspace_id, workspace_type_id and delete_flag. The request is expected to produce less than 500 lines.

    Here's the plan I make-

    Plan
    COUNCIL of the SELECT STATEMENT: FIRST_ROWSCost: 3 931 bytes: 405 108 cardinality: 7 502
    8 SORTING ORDER BY ORDER BY a.ITIME DESCCost: 3 931 bytes: 405 108 cardinality: 7 502
    7 LOOPS IMBRIQUEES EXTERNAL (ACCOUNT_WORKSPACE_TYPE at ACCOUNT_WORKSPACE_PA) in CUSTOM_GROUP_PACost: 3 930 bytes: 405 108 cardinality: 7 502
    3 LOOPS IMBRIQUEES ACCOUNT_WORKSPACE_TYPE to ACCOUNT_WORKSPACE_PACost: 2 280 bytes: 210 056 cardinality: 7 502
    1 INDEX UNIQUE INDEX (SINGLE) ADR_DEV SCAN. SYS_C0025442 aliased as cCost: cardinality of 0 bytes: 6: 1
    TABLE 2 ACCESS FULL TABLE ADR_DEV. ACCOUNT_WORKSPACE_PA alias ADR_DEV_DATA Tablespaceb.WORKSPACE_ID b! = - 9999, b.WORKSPACE_TYPE_ID = 1 b.DELETE_FLAG = 0Cost: 2 280 bytes: 165 044 cardinality: 7 502
    VIEW 6 (Embedded SQL) cost: 0 bytes: 26 cardinality: 1
    TABLE 5 ACCESS BY INDEX ROWID TABLE ADR_DEV. Aliased as one on ADR_DEV_DATA TablespaceCost CUSTOM_GROUP_PA: 04:00 cardinality: 1
    4 INDEX RANGE SCAN INDEX ADR_DEV. IDX_CG_WSID_DF_OWID aliased as aa.delete_flag (+) is NULL, a.delete_flag (+)! = 1, a.owner_id (+) = '123', a.workspace_id (+) = b.workspace_idCost: cardinality 3: 1


    If someone can advise, why I always make a full table scan on table account_workspace_pa and what I can do to have a systematic index scan?

    Thank you.

    If you need all the lines then that would be a clue do for you?

    You don't necessarily need a full table scan. But if you have need of all ranks, it is certainly more effective to do a full scan (read through all of the blocks table in bulk, once) rather than navigate throu an index and jump from block to block to block (probably one at a time, probably having to hit most of them more than once until the work is done) after the ROWID as they occur in the index.

    Also, fully entered null will not appear in the index, so (depending on your data, NOT NULL constraints, etc.) it may be possible that navigate through an index will cause lines to be ignored.

    I think you look at that and see a problem, but the answer is: it's really the best way to accomplish what you're asking.

  • By comparing the timestamp... columns i.e. cash matches between several passes

    I have a table with 10 columns to date (each date comes from a different data source) and would like to compare how "matches" (with a tolerance of time given... say 1 hour) between each of the columns.

    The result would be a matrix of 10 x 10 of values containing counts of correspondences between all combinations of date columns:
      
    Matches found:
        A  B  C
    A | 5  4  2
    B | 4  5  3
    C | 2  3  4  ** updated C-C from 5 to 4 because of potential null values in data
    I started using the box instructions, but I realize how much I would need to use and am sure someone out there has a better approach. Looks like some kind of self-join is useful?

    Any ideas?

    Published by: user8720636 on 25 Sep, 2009 08:13

    Hello

    AJ_son wrote:
    This solution works, but I was expecting a more 'elegant' way of managing the 10 x 10... I suspect that it may increase even more grand in the future.
    If there is no other ideas, I'm going with this method. Thank you.

    Yes, something less heavy is possible.
    Your original approach (comparing each column against each column) required c ^ 2 ^ comparisons (where c is the number of columns to date), and solution requred a c extra DECODE expressions of Boneist (each with branches c) pivot the data in the form that you want. So the complexity was in the order of 2 c ^ 2 ^
    Here is another way, which requires a CASE statement with branches c for data of the Nations United hub, and c. BOX simple expressions to convert data back and forth, making the total complexity 2 c.

    WITH   cntr        AS
    (
         SELECT     LEVEL     AS n
         FROM     dual
         CONNECT BY     LEVEL <= 3
    )
    ,     unpivoted_data         AS
    (
         SELECT     DENSE_RANK () OVER (ORDER BY t.ROWID)     AS rnum          -- use primary key instead of ROWID if you have one
         ,     cn.n
         ,     CASE     cn.n
                   WHEN  1  THEN  t.date_1
                   WHEN  2  THEN  t.date_2
                   WHEN  3  THEN  t.date_3
              END                         AS dt
         FROM          cntr          cn
         CROSS JOIN     temp_dates     t
    )
    SELECT       r.n                         AS date_checked
    ,       COUNT (CASE WHEN c.n = 1 THEN 1 END)     AS against_date_1
    ,       COUNT (CASE WHEN c.n = 2 THEN 1 END)     AS against_date_2
    ,       COUNT (CASE WHEN c.n = 3 THEN 1 END)     AS against_date_3
    FROM       unpivoted_data      r
    JOIN       unpivoted_data      c     ON     r.rnum     = c.rnum
                               AND     r.dt     BETWEEN      c.dt - :dif
                                       AND      c.dt + :dif
    GROUP BY  r.n
    ORDER BY  r.n
    ;
    

    Ann: dif is the permissible difference in days (for example ": dif: = 1/24;" means an hour).

    I have a table with 100 rows that I use instead of subqueries as cntr. It makes requests like that, but a little shorter and simpler, probably not any faster.

    If you are really looking for elegance, then maybe your data should be stored in the non swivel form in the first place. The fact that it makes sense to compare each column with the other column indicates that they are not so much attribute of another entity, as entities themselves. If you have stored data in a table that looked like the unpivoted_data above subquery, then you only need the main request.

  • By comparing the two huge table columns

    Hello

    I want to compare two tables each of RECON_APPEND_01 table contains 375 million and RECON_VS_24082011 450 million records.
    RECON_APPEND_01 is a normal table and RECON_VS_24082011 is range partitoned table.
    The two table has a primary key on the column Serial_number. (Oracle 11g R2)

    Requirment is to obtain the records in the RECON_APPEND_01 table that are not present in RECON_VS_24082011.
    I came across a few suggestions for using operator less. Here is the query and its plan to explain
    CREATE TABLE RECON_APPEND_01
    PARALLEL 3
    NOLOGGING
    AS
    ( SELECT   SERIAL_NUMBER
    FROM   RECON_APPEND_01
    minus
    select SERIAL_NUMBER from RECON_VS_24082011
    )
    Explain the Plan:
    --------------------------------------------------------------------------------------------------------------------------
    | Id  | Operation                    | Name            | Rows  | Bytes |TempSpc| Cost (%CPU)|    TQ  |IN-OUT| PQ Distrib |
    --------------------------------------------------------------------------------------------------------------------------
    |   0 | CREATE TABLE STATEMENT       |                 |   378M|  6451M|       |  1398K (43)|        |      |            |
    |   1 |  PX COORDINATOR              |                 |       |       |       |            |        |      |            |
    |   2 |   PX SEND QC (RANDOM)        | :TQ10002        |       |       |       |            |  Q1,02 | P->S | QC (RAND)  |
    |   3 |    LOAD AS SELECT            | RECON_APPEND_03 |       |       |       |            |  Q1,02 | PCWP |            |
    |   4 |     MINUS                    |                 |       |       |       |            |  Q1,02 | PCWP |            |
    |   5 |      SORT UNIQUE             |                 |   378M|  4336M|  7255M|   775K  (4)|  Q1,02 | PCWP |            |
    |   6 |       PX RECEIVE             |                 |   378M|  4336M|       |   114K  (3)|  Q1,02 | PCWP |            |
    |   7 |        PX SEND HASH          | :TQ10000        |   378M|  4336M|       |   114K  (3)|  Q1,00 | P->P | HASH       |
    |   8 |         PX BLOCK ITERATOR    |                 |   378M|  4336M|       |   114K  (3)|  Q1,00 | PCWC |            |
    |   9 |          TABLE ACCESS FULL   | RECON_APPEND_01 |   378M|  4336M|       |   114K  (3)|  Q1,00 | PCWP |            |
    |  10 |      SORT UNIQUE             |                 |   184M|  2115M|  3539M|   538K  (3)|  Q1,02 | PCWP |            |
    |  11 |       PX RECEIVE             |                 |   184M|  2115M|       |   216K  (1)|  Q1,02 | PCWP |            |
    |  12 |        PX SEND HASH          | :TQ10001        |   184M|  2115M|       |   216K  (1)|  Q1,01 | P->P | HASH       |
    |  13 |         PX BLOCK ITERATOR    |                 |   184M|  2115M|       |   216K  (1)|  Q1,01 | PCWC |            |
    |  14 |          INDEX FAST FULL SCAN| SYS_C002617302  |   184M|  2115M|       |   216K  (1)|  Q1,01 | PCWP |            |
    --------------------------------------------------------------------------------------------------------------------------
     
    Another alternate query:
    CREATE TABLE recon_append_02
    PARALLEL 3
    NOLOGGING
    AS
    SELECT   *
    FROM   RECON_APPEND_01 a
    WHERE   NOT EXISTS (SELECT  'X'
    FROM   RECON_VS_24082011 b
    WHERE   b.SERIAL_NUMBER = a.SERIAL_NUMBER)
    Explain the Plan:
    ------------------------------------------------------------------------------------------------------------
    | Id  | Operation              | Name            | Rows  | Bytes | Cost (%CPU)|    TQ  |IN-OUT| PQ Distrib |
    ------------------------------------------------------------------------------------------------------------
    |   0 | CREATE TABLE STATEMENT |                 |   378M|    26G|   450K (10)|        |      |            |
    |   1 |  PX COORDINATOR        |                 |       |       |            |        |      |            |
    |   2 |   PX SEND QC (RANDOM)  | :TQ10000        |   378M|    26G|   153K (28)|  Q1,00 | P->S | QC (RAND)  |
    |   3 |    LOAD AS SELECT      | RECON_APPEND_02 |       |       |            |  Q1,00 | PCWP |            |
    |   4 |     NESTED LOOPS ANTI  |                 |   378M|    26G|   153K (28)|  Q1,00 | PCWP |            |
    |   5 |      PX BLOCK ITERATOR |                 |       |       |            |  Q1,00 | PCWC |            |
    |   6 |       TABLE ACCESS FULL| RECON_APPEND_01 |   378M|    22G|   116K  (5)|  Q1,00 | PCWP |            |
    |   7 |      INDEX UNIQUE SCAN | SYS_C002617302  |     1 |    12 |     0   (0)|  Q1,00 | PCWP |            |
    ------------------------------------------------------------------------------------------------------------
    Based on the plan I've run the second query, but it's taking a lot of time around 4 hours and still running.
    Please suggest.

    With respect,
    Adeline Faure

    Look carefully at the request of Tubby. Your problem in your test is with b.val = null. You can't compare anything on a null using normal operators.

    SQL> select * from target_tab;
    
           VAL
    ----------
             1
             2
             3
             4
             5
             6
             7
             8
             9
            10
    
    SQL> select * from source_tab;
    
           VAL
    ----------
             6
             7
             8
             9
            10
    
    SQL> select a.*
      2  from target_tab a, source_tab b
      3  where a.val = b.val(+) and
      4        b.val is null;
    
           VAL
    ----------
             5
             1
             4
             2
             3
    

    John

  • Compare the min and max columns

    Hello

    I want to compare colum 1,2,5

    If max - min > 1 = failure

    How could I go making the?

    I think I should just remove all columns with 0, but I'm having a hard time to remove.

    can someone guide me how do.

    Thank you


  • help with my HorizontalFieldManager &amp; EditFields on the same line, 2nd column is not displayed

    Hi all, I've written a bean (called LabelAndEditField) that sets out a label and editfield as follows

    someLabel

    _________________

    |                                 |

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

    It seems to work perfectly when it is the only component on a line of a

    VerticalFieldManager

    now I want to reuse this compenent such that I can have a screen that looks like

    someLabel another label

    ______________              ______________

    |                                 |             |                                |

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

    and perhaps a third column.

    However, when you add my components of LabelAndEditField, the 2nd does not appear

    I used a HorizontalFieldManager and make

    HFM HorizontalFieldManager = new HorizontalFieldManager();

    HFM. Add (new LabelAndEditField ("someLabel"));

    HFM. Add (new LabelAndEditField ("another label"));

    then I just on the screen

    Add (hfm);

    but it does not show my second column, the second component of the LabelAndEditField

    Here is the snippet of code below, some can please help me get this to display

    (Sorry, that the code of my insert is wacked)

    public class LabelAndEditField extends VerticalFieldManager
    {
        private EditField _editField;
    
        public LabelAndEditField(String label,
                                 String initialValueOfTextField,
                                 int maxChars,
                                 long style)
        {
            super(NO_HORIZONTAL_SCROLL);
    
            add(labelField);
    
            HorizontalFieldManager textMgr = new HorizontalFieldManager(
                    Manager.NO_HORIZONTAL_SCROLL
                    | Manager.NO_HORIZONTAL_SCROLLBAR);
    
            _editField = new EditField("", initialValueOfTextField, maxChars,
                         style | EditField.NO_NEWLINE | EditField.FOCUSABLE
                         | EditField.NON_SPELLCHECKABLE
                         | Field.FIELD_VCENTER | Field.FIELD_LEFT);
    
            textMgr.add(_editField);
    
            add(textMgr);
    
        }
    
    }
    

    and the code that adds as that on the screen

    super(NO_HORIZONTAL_SCROLL); // this is a VerticalFieldManager
    
    HorizontalFieldManager rowMgr =
         new HorizontalFieldManager(Manager.NO_HORIZONTAL_SCROLL
                 | Manager.NO_HORIZONTAL_SCROLLBAR);
    
    LabelAndEditField col1=
           new LabelAndEditField("some label","initial value",12,Field.READONLY);
    
        LabelAndEditField col2=
           new LabelAndEditField("another some label","initial value",12,Field.READONLY);
    
    rowMgr.add(col1);
    rowMgr.add(col2);
    

    did anyone see anything wrong with that?

    As you can see for yourself, there is no place for the mktShare.  Try to go with FlowFieldManager and no HorizontalFieldManager as a container for your gadgets MyLabelAndEditField and see

    There is another possibility:

    The key in the code I provided is the super.layout (myWidth, maxHeight).  This myWidth tells your EditField its maximum size in pixels.  If you want to further restrict the domain, you have several options.  The only problem is - if you limit it too much, you will not be able to see the rest of the field.  To solve this, wrap your EditField (in which you now don't have to override the layout) in a HorizontalFieldManager (HORIZONTAL_SCROLL) (all this inside your MyLabelAndEditField) and limit the Manager rather than the field itself.  Then your customer will be able to scroll through the left field and right.

    In order to limit your HorizontalFieldManager, give him the width that you want in pixels (add that, as a parameter to the constructor of your MyLabelAndEditField) and substitute his sublayout like this:

    HorizontalFieldManager textMgr = new HorizontalFieldManager(Manager.HORIZONTAL_SCROLL | Manager.HORIZONTAL_SCROLLBAR) {
      protected void sublayout(int maxWidth, int maxHeight) {
        int myWidth = Math.min(_desiredWidth, maxWidth);
        super.sublayout(myWidth, maxHeight);
      }
    };
    

    Thanks to his style HORIZONTAL_SCROLL, the infield will be almost infinite width, so the EditField inside fortunately "will display" all his characters.

    Then, when you design your MyLabelAndEditField, give him a maximum pixel value.  Say, you want three areas in a row.  Take your Display.getWidth (), subtract the margins planned, divide by 3 and pass that value to each of these areas.  Then add them to a HorizontalFieldManager (line2mgr in your example) and check the result.

    You seem to be competent enough to easily integrate my illegible bubbles in your code - let us know the results.

Maybe you are looking for

  • BlackBerry Smartphone WIFI does work ' n

    Hello My Blackberry WIFI connection does not work correctly. My girlfriend has the same Blackberry and she isn't having problems. The difference is my pass. She has it with internet Blackberry from Vodafone. I got a pass from another provider with on

  • Is it possible to get the activation code of the older PC so that I can use it in my class?

    Original title: Activation of Windows 8. If there is some time I had windows 8 pro to use in my construction of future games. Not knowing I could install it on 1 computer (thought it would be at least 2) I installed it as a test on my desktop PC prev

  • Issues with broken links

    I added a few new themes in my file and saved. I went back in today and all my old subjects now say they have 0 links and have a red x through them. How to bring back my information?

  • all paying games it flashes back on the desktop

    I have a laptop of hp 2000 new sound while I'm playing games in the middle of the game it switches back on the desktop, hp y at - it a way to stop this, its very frustrating. Ms. washington

  • Bar formatting of navigational errors.

    HelloAfter the update my personal website of Adobe Muse created recently and the publication of Business Catalyst I started to notice mistakes in my navigation bar 'Shop' of formatting and for the life of me cannot know what is happening.  All the pr