compare the fields of two queries

I need to compare the fields of two queries.

I went through many articles to asktom help operator less. but I'm not convinced by this method.

Comaprisons are for about 10 fields.

So I'm planing to do using sliders and nested loops. performance can be a problem.

Please give your suggestions or solutions.

OK, using the data you provided, I get this:

with map_test_fac as (select 100 idid, 789 ifid, 300 edid, 741 efid from dual union all
                      select 100 idid, 123 ifid, 300 edid, 963 efid from dual union all
                      select 100 idid, 456 ifid, 300 edid, 258 efid from dual),
         test_fac as (select 741 facid, 'ETY' type, 'EUR' ccy, 'Ext' src, 300 did from dual union all
                      select 789 facid, 'WE' type, 'EUR' ccy, 'Int' src, 100 did from dual union all
                      select 123 facid, 'VPR' type, 'EUR' ccy, 'Int' src, 100 did from dual union all
                      select 456 facid, 'ETY' type, 'USD' ccy, 'Int' src, 100 did from dual union all
                      select 963 facid, 'WE' type, 'EUR' ccy, 'Ext' src, 300 did from dual union all
                      select 258 facid, 'VPR' type, 'EUR' ccy, 'Ext' src, 300 did from dual)
-- end of mimicking your data: USE SQL below:
select tfi.facid int_facid,
       tfi.type int_type,
       tfi.ccy int_ccy,
       tfi.src int_src,
       tfi.did int_did,
       tfe.facid ext_facid,
       tfe.type ext_type,
       tfe.ccy ext_ccy,
       tfe.src ext_src,
       tfe.did ext_did
from   test_fac tfi,
       test_fac tfe,
       map_test_fac mtf
where  mtf.ifid = tfi.facid
and    mtf.efid = tfe.facid
and    mtf.idid = tfi.did
and    mtf.edid = tfe.did
and    (tfi.type != tfe.type
        or tfi.ccy != tfe.ccy)

 INT_FACID INT INT INT    INT_DID  EXT_FACID EXT EXT EXT    EXT_DID
---------- --- --- --- ---------- ---------- --- --- --- ----------
       789 WE  EUR Int        100        741 ETY EUR Ext        300
       123 VPR EUR Int        100        963 WE  EUR Ext        300
       456 ETY USD Int        100        258 VPR EUR Ext        300

However, I think that your mapping data is incorrect, so with keys of information:

with map_test_fac as (select 100 idid, 789 ifid, 300 edid, 963 efid from dual union all
                      select 100 idid, 123 ifid, 300 edid, 258 efid from dual union all
                      select 100 idid, 456 ifid, 300 edid, 741 efid from dual),
         test_fac as (select 741 facid, 'ETY' type, 'EUR' ccy, 'Ext' src, 300 did from dual union all
                      select 789 facid, 'WE' type, 'EUR' ccy, 'Int' src, 100 did from dual union all
                      select 123 facid, 'VPR' type, 'EUR' ccy, 'Int' src, 100 did from dual union all
                      select 456 facid, 'ETY' type, 'USD' ccy, 'Int' src, 100 did from dual union all
                      select 963 facid, 'WE' type, 'EUR' ccy, 'Ext' src, 300 did from dual union all
                      select 258 facid, 'VPR' type, 'EUR' ccy, 'Ext' src, 300 did from dual)
-- end of mimicking your data: USE SQL below:
select tfi.facid int_facid,
       tfi.type int_type,
       tfi.ccy int_ccy,
       tfi.src int_src,
       tfi.did int_did,
       tfe.facid ext_facid,
       tfe.type ext_type,
       tfe.ccy ext_ccy,
       tfe.src ext_src,
       tfe.did ext_did
from   test_fac tfi,
       test_fac tfe,
       map_test_fac mtf
where  mtf.ifid = tfi.facid
and    mtf.efid = tfe.facid
and    mtf.idid = tfi.did
and    mtf.edid = tfe.did
and    (tfi.type != tfe.type
        or tfi.ccy != tfe.ccy)

 INT_FACID INT INT INT    INT_DID  EXT_FACID EXT EXT EXT    EXT_DID
---------- --- --- --- ---------- ---------- --- --- --- ----------
       456 ETY USD Int        100        741 ETY EUR Ext        300

That's more like what you're looking for?

Tags: Database

Similar Questions

  • Compare the content of two equal nested tables

    I'm working on a black box test where I compare the contents of two structurally equal tables before and after executing a script of some. My two tables, MDQ_OLD and MDQ_NEW, are filled with the data in two separate operations.

    The two tables, I'll compare are nested, as you can see in the CREATE TABLE scripts below.

    I tried to use the less-operator sign, but without success.

    I also tried to select data in a type that is % ROWTYPE to my nested tables, but it does not work as well (see the below script in this post).

    Can you please help me on this problem on how to compare the content of two nested tables?

    Run the scripts below to reproduce the problem and be sure to update this post if more information is required.

    -The scripts below-

    Select * from version of v$.

    Oracle Database 11 g Enterprise Edition Release 11.2.0.4.0 - 64 bit Production

    PL/SQL Release 11.2.0.4.0 - Production

    CORE Production 11.2.0.4.0

    AMT for Linux: Version 11.2.0.4.0 - Production

    NLSRTL Version 11.2.0.4.0 - Production

    -First of all, I create my types

    CREATE OR REPLACE TYPE FORCE AS OBJECT MDQ_DETAIL (NUMBER OF MDQ_DETAIL_ID, MDQ_DETAIL_DESC VARCHAR2 (100));

    CREATE OR REPLACE TYPE T_MDQ_DETAIL AS TABLE MDQ_DETAIL;

    -Note that this type contains the table T_MDQ_DETAIL type:

    CREATE OR REPLACE TYPE MDQ_PARENT FORCE AS OBJECT (NUMBER MDQ_ID, MDQ_DETAILS T_MDQ_DETAIL);

    - Then I create two equal nested tables

    CREATE THE NESTED TABLE AS MDQ_PR_OLD STORE MDQ_DETAILS MDQ_PARENT MDQ_OLD TABLE.

    CREATE THE NESTED TABLE AS MDQ_PR_NEW STORE MDQ_DETAILS MDQ_PARENT MDQ_NEW TABLE.

    -Insert test data in the nested tables

    Insert into MDQ_OLD (MDQ_ID, MDQ_DETAILS) Values (1, T_MDQ_DETAIL (MDQ_DETAIL(1,'desc1')));

    Insert into MDQ_NEW (MDQ_ID, MDQ_DETAILS) Values (2, T_MDQ_DETAIL (MDQ_DETAIL(1,'desc1')));

    -Try to use the negative operator to compare the contents of the trailer of the nested tables, but it gives this error:

    -ORA-00932: inconsistent data types: expected - got DISPATCH. T_MDQ_DETAIL

    Select * from MDQ_NEW

    less

    Select * from MDQ_OLD;

    -Try to select in a ROWTYPE, but it fails

    declare

    myTypeOld MDQ_OLD % ROWTYPE;

    myTypeNew MDQ_New % ROWTYPE;

    myTypeDiff MDQ_New % ROWTYPE;

    Start

    -Select gives: PLS-00497: do not mix between row and several rows (in BULK) list

    Select * bulk collect into mdq_old myTypeOld;

    Select * bulk collect into mdq_new myTypeNew;

    -Need a 'compare the function of membership card' on the types of multiset except to work, but as far as I

    -I'm not able to bulk collect into myTypeOld or myTypeNew, this won't help out me.

    myTypeDiff: = multiset myTypeOld except myTypeNew.

    end;

    -Cleaning:

    drop table MDQ_OLD;

    drop table MDQ_NEW;

    type of projection MDQ_PARENT;

    type of projection T_MDQ_DETAIL;

    type of projection MDQ_DETAIL;

    > queries you provided intercepts not who.

    You asked how to compare the content of nested tables.

    I knew that you didn't ask for what you actually want, that's why I asked you to specify the comparison more in detail.

    > Do you have a query that grabs this difference as well?

    SELECT o.mdq_id, od.*
    OF mdq_old o, TABLE (o.mdq_details) od
    LESS
    SELECT n.mdq_id, nd.*
    OF mdq_new n, TABLE (n.mdq_details) nd;

    > Also, if possible, do you have a sample of a statement to COLLECT LOOSE, please?

    Actually, you raise an interesting point on using % ROWTYPE, in my view, that should be. This make...

    DECLARE
    TYPE rt_mdq_new () IS RENDERING
    mdq_id NUMBER,
    mdq_details t_mdq_detail);
         
    TYPE tt_mdq_new IS TABLE OF THE rt_mdq_new;
      
    t_mdq_new tt_mdq_new;
    BEGIN
    SELECT mdq_id, mdq_details
    LOOSE COLLECTION t_mdq_new
    OF mdq_new min.;
    END;
    /

    DECLARE
    CURSOR c_mdq_new
    IS
    SELECT mn.*
    OF mdq_new min.;
         
    TYPE tt_mdq_new IS TABLE OF c_mdq_new % ROWTYPE;
      
    t_mdq_new tt_mdq_new;
    BEGIN
    OPEN c_mdq_new.
    Get the c_mdq_new COLLECT in BULK IN t_mdq_new;
    CLOSE C_mdq_new;
    END;
    /

  • How to compare the content of two files so I can delete duplicate records

    I'm trying to clean up several subfolders with duplicates without looking at the details of each record.  Is it possible in Windows XP to compare the content of two files whether they are an exact replica.

    Hi rav42010,

    Follow the steps in the article.

    Description of the tool in Windows XP disk cleanup

    http://support.Microsoft.com/kb/310312

    You can also use third-party app to perform the task using your favorite search engine.

    Note: Using third-party software, including hardware drivers can cause serious problems that may prevent your computer from starting properly. Microsoft cannot guarantee that problems resulting from the use of third-party software can be solved. Software using third party is at your own risk.

  • How to compare the content of two Wordpad / documents notebook without reading them line by line?

    How to compare the content of two Wordpad / documents notebook without reading them line by line?

    Hello

    Without this feature is included in the operating system.

    However, you can use your favorite search engine to look for software that needs to perform these tasks.

    WARNING of THIRD PARTY SOFTWARE: Using third-party software, including hardware drivers can cause serious problems that may prevent your computer from starting properly. Microsoft cannot guarantee that problems resulting from the use of third-party software can be solved. Software using third party is at your own risk.

    Hope this information helps.

  • By comparing the fields on a JSPX

    OK, this should not be difficult, but I can't find anything on it.

    I want to do is compare two fields, in this case the dates on a form.

    Now, the tricky part seems to get values that are CURRENTLY in the form of type.

    I need a way to see what the user has typed currently on the form. Why is it so difficult? (or apparently?)

    He compares the value that was stored in the line, but this will only confuse the user:

    ' Public Sub StartDate_validator (FacesContext facesContext, UIComponent uIComponent object pObject)
    {
    RichInputDate vReturnDateComponent = uIComponent.findComponent ("id1") (RichInputDate);
    VReturnDate = vReturnDateComponent.getValue () (Date);
    Day vStartDate = pObject of (Date);
    System.out.println ("to start date" + vReturnDate.compareTo (vStartDate));

    If (vReturnDate.compareTo (vStartDate) < 0)
    {
    throw new ValidatorException (new FacesMessage (FacesMessage.SEVERITY_ERROR, "invalid leave", null));
    }
    }

    ' Public Sub ReturnDate_validator (FacesContext facesContext, UIComponent uIComponent object pObject)
    {
    RichInputDate vStartDateComponent = uIComponent.findComponent ("id2") (RichInputDate);
    VStartDate = vStartDateComponent.getValue () (Date);
    Day vReturnDate = pObject of (Date);
    System.out.println ("on the date of return" + vReturnDate.compareTo (vStartDate));

    If (vReturnDate.compareTo (vStartDate) < 0)
    {
    throw new ValidatorException (new FacesMessage (FacesMessage.SEVERITY_ERROR, "invalid return", null));
    }

    }

    < af:panelGroupLayout id = "pghb" layout = "vertical" >
    < af:inputDate value = "#{bindings." AutoSubmit DepartDate.inputValue}' = 'true '.
    label = "#{bindings." DepartDate.hints.label}.
    required = "#{bindings." DepartDate.hints.mandatory}.
    shortDesc = "#{bindings." DepartDate.hints.tooltip}"id ="id2 ".
    immediate = "true".
    Validator = "#{backingBeanScope.UpdateTABean.StartDate_validator}" >
    < f: validator binding = "#{bindings." DepartDate.validator} "/ >"

    <!-->
    < af:convertDateTime pattern = "#{bindings." DepartDate.format} "/ >"
    < / af:inputDate >
    < af:inputDate value = "#{bindings." AutoSubmit ReturnDate.inputValue}' = 'true '.
    label = "#{bindings." ReturnDate.hints.label}.
    required = "#{bindings." ReturnDate.hints.mandatory}.
    shortDesc = "#{bindings." ReturnDate.hints.tooltip}"id ="id1"immediate ="true ".
    Validator = "#{backingBeanScope.UpdateTABean.ReturnDate_validator}" >
    < f: validator binding = "#{bindings." ReturnDate.validator} "/ >"
    < af:convertDateTime pattern = "#{bindings." ReturnDate.format} "/ >"
    < / af:inputDate >
    < / af:panelGroupLayout >

    Thank you

    Jet

    Hello

    Try to set up each component of entry as one partialTrigger on the other. I think it should work.

    It has to do with the life cycle JSF/ADF. It becomes a bit complicated because of the autoSubmits and the immediate you have on components. Learn more about the cycle of life and its variants here: http://docs.oracle.com/cd/E15523_01/web.1111/b31973/af_lifecycle.htm

  • Is it possible to compare the contents of two folders

    Someone copied one of our folders with subfolders on the server from one place to the other. Now, some people use the old location and the new location. Is it possible to compare the two, to find the difference and merge them into a file without losing any information?

    There are third party tools that can automate a large part of it, but you still need to judge what part gets merged from which file.  One of those tools that I know is "Beyond Compare"

    Beyond Compare: <> http://www.scootersoftware.com/index.php >

    Not free, but in my humble OPINION is worth the price.

    HTH,

    JW

  • How can I compare the differences between two files After Effects?

    I have a major problem.  I was working on special effects for a film.  In After Effects, when I change siggificant, I often have to register under and create a new name so I can go back to the old work if necessary.  It comes in a case, I have come back from earlier works.  If I use these two files After Effects allows you to create multiple clips of effects.  And I do not remember just where you look at it, it is better.  Does anyone know a good way to compare the differences between the files?

    One thing to keep this conversation on the right way: I know that I did a stupid thing.  I've never done this before so can we please not spend a lot of time on how to avoid this problem and stick to how we solve this problem?

    If you encounter difficulties to identify differences in the old and new versions, you can use this procedure:

    To avoid confusion, I'll call your former company and your most recent compositions CompB comps.

    CompA drag "New Comp" icon in the project window.  This will create a new temporary layout that contains the nested CompA.

    Drag in your new COMP CompB temporary ensure it aligns image for image with CompA.

    Place the top layer (CompB) difference.

    Now, when you play through the comp, you'll see differences in color at a time where the comparison and CompB are not identical.

  • How to compare the value of two combo

    I have two Combo Box (cbFirst & cbSecond). I want to compare the value that has been selected by the user and according to the result, the output is displayed. In the two combo box, I have provided the value.

    Here is my code:

    var a: number;
    var b:Number;

    function First(evt:Event):void {}
    a = evt.target.value;
    trace (a);
    }
    cbFirst.addEventListener (Event.CHANGE, first);

    function Second(evt:Event):void {}
    b = evt.target.value;
    trace (b);
    }
    cbSecond.addEventListener (Event.CHANGE, second);

    If (a > b) {}

    trace ("more")

    on the other

    trace (b is higher);

    Trace the statement inside the functions work very well and the value correct a & b is printed. But the comparison in the if statement does not seem to work. Could you please help me.

    There is a typing error.  Fix it or delete it:

    var a: number;
    var b:Number;

    function First(evt:Event):void {}
    a = evt.target.value;

    trace (a);
    compareF();
    }
    cbFirst.addEventListener (Event.CHANGE, first);

    function Second(evt:Event):void {}
    b = evt.target.value;
    trace (b);

    compareF()
    }
    cbSecond.addEventListener (Event.CHANGE, second);

    function compareF() {}

    If (a > b) {}

    trace ("more")

    on the other

    trace (b is higher);

    }

  • I want to compare the 'brightness' of two images using a template image and an image acquired

    For the most part looking for suggestions on the best way to go about it. Im trying to run a test that will allow me to compare the brightness of an LCD screen using a webcam. Essentially, I let power on the screen, and from time to time, the screen will be incredibly dim. IM thinking I should be able to use the functionality of the subtraction with both images and if I have a normal screen it should produce a closure to 0 results, while the dark screen should give a non zero value (pixel wise) but have so far not been successful.

    http://zone.NI.com/reference/en-XX/help/370281AA-01/imaqvision/imaq_light_meter__point/  I used the rectangle version but this block instead of going with a subtraction! Being new on and auto teaching labview I often oversteps these easy solutions

  • When comparing the fields status, title or banner buried on the body of the screen?

    When you have a screen and you have the added fields to the body as well as the status bar, I wonder when that gets buried on? What is the sequence of events?

    During the positioning of the body.

  • Results of the difference of two queries with a result zero

    Hello

    I use a query, as shown in the following example:

    SELECT the vault, id1 - id2, wf1 - wf2 tr1 - tr2 OF
    (SELECT sc, SUM (id1), SUM (wf1), SUM (tr1) FROM table1 GROUP BY sc) a.,
    (SELECT sc, SUM (id2), SUM (wf2), (tr2) SUM OF table2 GROUP BY sc) b
    WHERE arch = BSC.

    The results are good, but I have the problem if the baccalaureate is NULL that I get a result for the values. What I need, is that the result should show the vault and other values, if the degree is NULL.

    As

     SQL> select distinct deptno from emp
      2  /
    
        DEPTNO
    ----------
            30
            20
            10
    
    SQL> select deptno from dept
      2  /
    
        DEPTNO
    ----------
            10
            20
            30
            40
    
    SQL> select
      2     nvl(e.deptno, d.deptno) , nvl(e.c1,d.c1)
      3  from
      4     (select deptno, count(*) c1 from emp group by deptno ) e,
      5     (select deptno, count(*) c1 from dept group by deptno ) d
      6  where
      7     e.deptno (+) = d.deptno
      8  /
    
    NVL(E.DEPTNO,D.DEPTNO) NVL(E.C1,D.C1)
    ---------------------- --------------
                        30              6
                        20              5
                        10              3
                        40              1
    
    SQL>
    

    Published by: s_2 on November 3, 2008 17:37

  • How compared the content of the two cards

    Hello

    How can I compare the contents of two cards that look like:

    Private map < String, < String, Enum > map > expected;

    Private map < String, < String, Enum > map > real;

    BR,

    Mike

    Actual.Equals (expected);

  • Need a better query... Join the indictments of two separate queries...

    Hi all

    I have two separate tables. Initially, I write separate queries to get the number of these tables... Now my requirement is to get the sum of the counts of two queries and I need to write to in a query of monkey...

    I wrote something like below... is there any query better than that...
    select count  as total from (select distinct site_code,cd_conv_to FROM AA.AAT_440_SVA_DETAIL A , AA.CONV_DETS B , GB.GBT_A02_SITE C WHERE A.PLANT_CODE=B.CD_CONV_FROM AND CD_CONV_TYPE='GSPSPLRG' AND A.SCODE=C.SCODE AND SCODE >= 'C' UNION ALL select distinct T_MANU,cd_conv_to  FROM AA.AAT_447_ISP_Q A , AA.CONV_DETS B , GBT.GBTSITE C WHERE STATUS='VAT' AND A.PCODE=B.CD_CONV AND CD_CONV='GSP' AND A.CD_DIRECT=C.SCODE AND CD_DIRECT >= 'C') q1
    Thank you
    ASP.

    Hello

    Try:

    SELECT NVL(ilv1.cnt1,0) cnt1, NVL(ilv2.cnt2, 0) cnt2, NVL(ilv1.cnt1, 0) + NVL(ilv2.cnt2,0) total_cnt
      FROM (
      SELECT COUNT(distinct site_code,cd_conv_to) cnt1
         FROM AA.AAT_440_SVA_DETAIL A , AA.CONV_DETS B , GB.GBT_A02_SITE C
      WHERE A.PLANT_CODE=B.CD_CONV_FROM
          AND CD_CONV_TYPE='GSPSPLRG'
          AND A.SCODE=C.SCODE AND SCODE >= 'C' ) ilv1,
      (SELECT COUNT(distinct T_MANU,cd_conv_to) cnt2
          FROM AA.AAT_447_ISP_Q A , AA.CONV_DETS B , GBT.GBTSITE C
       WHERE STATUS='VAT'
        AND A.PCODE=B.CD_CONV
        AND CD_CONV='GSP'
        AND A.CD_DIRECT=C.SCODE AND CD_DIRECT >= 'C') ilv2
    
  • iDoc Script to compare the metadata

    Scenario:

    Customers has a workflow approvers reviewers are selected when check-in, metadata and metadata xRevisors, xApprovers, is the list of multiple options and a table users view. But, the author, reviewer, and approver cannot be the same person. I create an iDoc Script to check for this, in the first step of the workflow:

    < $if author as "xRevisors" or dDocAuthor as 'xApprovers' or xRevisors like $ "xApprovers" >

    < $wfSet ("wfJumpName", "Check_participantes") $>

    < $wfSet ("wfJumpTargetStep", "contribution@HmbGgqDocQualidade") $>

    < $wfSet ("wfJumpEntryNotifyOff", "0") $>

    < $wfSet ("wfJumpMessage", "author, reviewer, and approver cannot be the same person.") ") $>

    < $endif$ >

    This work when I choose as a reviewer or an approver, but stand them sometimes more than one person and that's my problem, xRevisors and xApprovers metadata save more than one user, then author as reviewer or approver compare it is false. How to make the script check this?

    Or just convert the strings separated by commas results (<$rsMakeFromString$>) and loop games result sets.  This should be fairly simple.

    On another note, I see even where this line of code would work.

    <$if author="" like="" "xrevisors"="" or="" ddocauthor="" like="" "xapprovers"="" or="" xrevisors="" like="" "xapprovers"$="">-It's not comparing the fields, he compares a literal string, namely "is the value of the author as the word"xRevisors "?  How does this even in the first place?

  • Compare the contents of the table

    Hi all

    11.2.0.3

    I have EMP_OUT tables both in the database of PROD and UAT. They came out of batch programs run in parallel.

    I want to compare the content of two such identical tables.

    How can I achieve this?

    Thank you all,

    pK

    I don't know that it is very clear in the general forum you think like Tom.

    I look forward to your blog...

Maybe you are looking for