Compare two records within a view

Hi,
I wonder if it is possible to compare two or more records within a view, and how to do it.
Thanks in advance.

M. Comi wrote:
I wanted to compare two records of the view and see if they are the same or not...
My data are as follows:
Soglia Ingresso_CL_PF     10     10
Downgrade MDP 3     2102     2101
I want to check if the "downgrade" records have the same values for the second and the third column, and in this case replace the values on the second record.
But I did it with a select on the same fields of the original tables, plus two fields obtained with lag function...
I don't know if it is clear or not, the important is that I got what I wanted.Sorry, it's not clear.
Are you still having a problem? If so:
(1) Please describe the problem.
(2) What results do you want to see from the sample data you posted?
(3) Is the second column of
Downgrade MDP 3 2102 2101'Downgrade', 'MDP', 3, 2102, 2101, some combination, or NULL? When posting data, the most helpful thing is to post INSERT (or CREATE TABLE AS ...) statements. The second-best thing is to post formatted data. Type {code} before and after sections where spacing is important, and post column headers.

Similar Messages

  • How to compare two records of table

    Hi all,
    How to compare new record with all existing records in table.
    In my application i have status column ,which contains the information about
    the record is new or old record .
    thank you

    /*does record 1 have friend*/
    WITH t AS
    (SELECT 1 AS Id, 'a' AS NAME, 'type1' AS Col
      FROM Dual
      UNION ALL
      SELECT 2 AS Id, 'a' AS NAME, 'type1' AS Col
      FROM Dual
      UNION ALL
      SELECT 3 AS Id, 'a' AS NAME, 'type2' AS Col FROM Dual)
    SELECT count(*) as YesNo
    FROM t T1
    WHERE T1.Id = 1
          AND (T1.Name, T1.Col) IN (SELECT T2.Name, T2.Col FROM T t2 where t2.ID != T1.Id);
         1
    /*does record 3 have friend*/
    WITH t AS
    (SELECT 1 AS Id, 'a' AS NAME, 'type1' AS Col
      FROM Dual
      UNION ALL
      SELECT 2 AS Id, 'a' AS NAME, 'type1' AS Col
      FROM Dual
      UNION ALL
      SELECT 3 AS Id, 'a' AS NAME, 'type2' AS Col FROM Dual)
    SELECT count(*) as YesNo
    FROM t T1
    WHERE T1.Id = 3
       AND (T1.Name, T1.Col) IN (SELECT T2.Name, T2.Col FROM T t2 where t2.ID != T1.Id);
         0
    */

  • Comparing two records from different tables error.

    Hi folks!
    I have this PL/SQL Block.
    I want to compare the only one record from both tables to see if the content of them are equal or not, but I don't want to specified column by column to do that.
    Any idea?
    Thanks a lot in advanced,
    Abdel E. Miranda S.
    Panama
    declare
    cursor c_aems_prueba is
    select nombre, direccion, telefono, limite, seq
         from aems_prueba;
    cursor c_aems_testing is
    select nombre, direccion, telefono, limite, seq
         from aems_testing;
    vc_aems_prueba c_aems_prueba%rowtype;
    vc_aems_testing c_aems_testing%rowtype;
    vt_aems_prueba aems_prueba%rowtype;
    vt_aems_testing aems_testing%rowtype;
    begin
    insert into aems_prueba
    values('ABDEL MIRANDA', 'PAITILLA', '215-3411', 1000, 1);
    insert into aems_testing
    values('ABDEL MIRANDA', 'PAITILLA', '215-3411', 1000, 1);
    commit;
    open c_aems_prueba;
    fetch c_aems_prueba into vt_aems_prueba;
    open c_aems_prueba;
    fetch c_aems_prueba into vt_aems_testing;
    if vt_aems_prueba = vt_aems_prueba
    then
         dbms_output.put_line('son iguales las variables, si funciona la comparacion de dos estructuras');
         else
         dbms_output.put_line('no son iguales las variables, no funciona la comparacion de dos estructuras');
    end if;
    close c_aems_prueba;
    close c_aems_testing;
    end;

    Satyaki De,
    Java is involving because an Outsourcing new project. The outsourcing company is developing the new application using JSF which invoke an interface java method [depending of the operation: select, update, insert] and them invoke the PLSQL API to precess tha operation.
    In the case I already wrote here, the issue is this:
    The user search for a specific data using the interface. The java method send a request for these operation through the API. the PLSQL process the request and return a beam, with all the column the user look for.
    The user see the information in the application windows. Assuming the user wants to change some data, he modify just one field [lets say telephone number] and press the update button. The application process the request using a different method, which invoke a different function within the PLSQL API.
    Once the information is returning to the API, I must know if at least one field change its value. So I was thinking to get the beam with the data before it was changed and compare it with the beam with the changing data.
    If current_beam = new_beam
    then
    update
    else
    no change to process
    end if;
    Any idea.

  • Compare two records column by column in same table

    Hi All,
    I have an address table with ID as the PK but there can be more than one ID. I need to take the latest address record and first see if that same ID has a previous address record and if so, compare each column to see if the data has changed. I only need to compare the latest record with the next latest record.
    I cannot figure this out at all. I can of course use the MAX function to get the latest address records but do not know how I can pull the next latest address record that matches the ID and compare each column.
    Sample table:
    ID street city state zip effective_date
    1 123 main chicago IL 60111 3-7-2012
    2 34 N 13th new york NY 18374 3-7-2012
    3 15 N main Dallas TX 47389 3-7-2012
    1 89 N main chicago IL 60111 1-5-2012
    1 16 East St columbus OH 47382 12-10-2011
    2 34 N 13th new york NY 18374 10-7-2011
    2 15 S Elm new york NY 18374 09-1-2011
    3 15 N main Dallas TX 47389 10-4-2011
    SO...in the table above using today as the latest record date, based of my criteria I would only want to pull record ID 1 and 2 since the next most recent record for those IDs have had at least one of their address data change. ID 3 has exactly the same address data so I would not consider that in my criteria.
    Can i do this with SQL only or will i need to create a procedure or function?
    Any help is appreciated
    Ben

    Ben C wrote:
    Hi All,
    I have an address table with ID as the PK but there can be more than one ID. You mean there can be more than one row with tha same ID, right? (There can be more than one ID, also.)
    I need to take the latest address record and first see if that same ID has a previous address record and if so, compare each column to see if the data has changed. I only need to compare the latest record with the next latest record.
    ... Sample table:Whenever you have a problem, please post CREATE TABLE and INSERT statements for the sample data, and the exact results you want from that data.
    Explain, using specific examples, how you get those results from that data.
    Always say which version of Oracle you're using.
    Can i do this with SQL only or will i need to create a procedure or function?You don't need PL/SQL, if I understand your requirements. You can do something like this:
    WITH     got_analytics     AS
         SELECT     id, street, city, state, zip, effective_date
         ,     COUNT (*)     OVER ( PARTITION BY  id )          AS cnt
         ,     ROW_NUMBER () OVER ( PARTITION BY  id
                                   ORDER BY          effective_date     DESC
                           )                           AS r_num
         FROM    table_x
    --     WHERE     ...     -- If you need any filtering, put it here
    SELECT    id, street, city, state, zip, effective_date
    FROM       got_analytics
    WHERE       cnt     > 1
    AND       r_num     <= 2
    ORDER BY  id
    ,            effective_date
    ;This will show the most recent 2 rows for each id that has 2 (or more) rows.
    You can modify it to only include ids where there was some change in street, city, state or zip between those 2 rows.
    WITH     got_analytics     AS
         SELECT     id, street, city, state, zip, effective_date
         ,     COUNT (*)     OVER ( PARTITION BY  id )          AS cnt
         ,     ROW_NUMBER () OVER ( PARTITION BY  id
                                   ORDER BY          effective_date     DESC
                           )                           AS r_num
         FROM    table_x
    --     WHERE     ...     -- If you need any filtering, put it here
    ,     got_unique_cnts     AS
         SELECT     id, street, city, state, zip, effective_date
         ,     COUNT (DISTINCT '~' || street) OVER (PARTITION BY id)     AS street_cnt
         ,     COUNT (DISTINCT '~' || city)   OVER (PARTITION BY id)     AS city_cnt
         ,     COUNT (DISTINCT '~' || state)  OVER (PARTITION BY id)     AS state_cnt
         ,     COUNT (DISTINCT '~' || zip)    OVER (PARTITION BY id)     AS zip_cnt
         FROM       got_analytics
         WHERE       cnt     > 1
         AND       r_num     <= 2
    SELECT    id, street, city, state, zip, effective_date
    FROM       got_unique_cnts
    WHERE       street_cnt     > 1
    OR       city_cnt     > 1
    OR       state_cnt     > 1
    OR       zip_cnt     > 1
    ORDER BY  id
    ,            effective_date
    ;This assumes that street, city, state and zip are all VARCHAR2s. If any of those columns is NULL on one row, and not NULL on the other row for that ID, that counts as a difference.
    Edited by: Frank Kulash on Mar 7, 2012 3:37 PM
    Edited by: Frank Kulash on Mar 7, 2012 3:41 PM

  • How can I compare two collections at the same time? (View two grid views)

    I have two collections containing some of the same images. (My Nikon D70 did not put an end-of-file on some images. I recovered them into a different collection.) Now I want to display both collections side-by-side in grid view. I will select those images in the "recovered" collection that correspond to the bad images in the "main" collection, add the ratings etc, and move just these to another collection.
    It is extremely frustrating to have to bounce back and forth between collections, remembering each image one by one and selecting it in the "recovered" collection. (The image names are not preserved in the "recovered" collection -- I have to go by what the image looks like.)
    LightRoom allows me to compare photos in the compare view. I want to compare collections in two grid views.

    CaptureTheLight,
    you have ran into a situation when you have to compare two sets of images and now you're wondering how come Lightroom doesn't have such "obviously necessary" functionality? But you have to admit it, this is not such a common situation in a photographer's workflow recovers broken files and tries to compare them against themselves. I think it's a pretty specific feature you need. Still, Lightroom has enough powerful tools for editing and sorting images.
    For example...
    You could just put them all - "main" and "recovered" - into a single collection or into the Quick Collection. Label the entire "recovered" collection with, say, red and sort by capture time. Now you'll have everything side by side, ordered chronologically. The "recovered" images will stay next to the "main" images since their capture time will be the same, and they will also stand out since they have the red label.
    Make the thumbnails bigger and set up the grid view so it tints the thumbnail cell are tinted with the label color. Now, you can go quickly through them visually checking labeled vs unlabeled.

  • How can i compare two excel files with different no. of records.

    Hi
    I am on to a small project that involves us to compare two excel files. i am able to do it but am struck up at a point. When i compare 2 different .csv files with different no. of lines i am only able to compare upto a point till when the number of lines is same in both the files.
    Eg. if source file has 8 lines and target file has 12 lines. The difference is displayed only till 8 lines and the remaining 4 lines in source lines are not shown.
    Can you help me in displaying those extra 4 lines in source file. I am attaching my code snippet below..
    while (((strLine = br.readLine()) != null) && ((strLine1 = br1.readLine())) != null)
                     String delims = "[;,\t,,,|]";
                    String[] tokens = strLine.split(delims);
                    String[] tokens1 = strLine1.split(delims);
                   if (tokens.length > tokens1.length)
                    for (int i = 0; i < tokens.length; i++) {
                        try {
                            if (!tokens.equals(tokens1[i])) {
    System.out.println(tokens[i] + "<----->" + tokens1[i]);
    out.write(sno + " \t" + lineNo1 + " \t\t" + tokens[i] + "\t\t\t\t" + tokens1[i]);
    out.println();
    sno++;
    } catch (Exception exception)
    out.write(sno + " \t" + lineNo1 + " \t\t" + tokens[i] + "\t\t\t\t" + "");
    out.println();
    Thanks & Regards                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    A CSV file is not an Excel file.
    But apart from that your logic makes no sense.
    If the 2 files are of different sizes the files are different by definition, so further comparison isn't needed, you're done.
    If you want to compare individual records, you need to compare all records from one file with all records from the other, unless the order of records is important in which case your current system might work.
    That system however is overly complicated for comparing CSV files.
    As you assume a single record per line, and if one can assume those records to have identical layout (so no leading or trailing whitespace in or between columns in one file that's not in the other) comparing records is simply a matter of comparing the entire lines.

  • Comparing two data records of same IDOC

    Hi,
    In PI, we need to compare two data records of same IDOC to figure out if what type change occurred.  For example, BENFIT3 IDOC contains data records tilted "E1BEN04".  When there are multiple "E1BEN04" data records, then we need to compare the data inside them to see whether name, or data of birth or SSN is changed. 
    Has anybody came across this before. Your help is much appreciated.
    Thanks
    -Teja

    If it is very few fields then you could use graphical mapping to determine the changes.

  • How to compare two views/tabels from two systems via RFC

    Hello
    How to compare two views/tabels from two systems via RFC. I know there is a transactio or program but which

    Hi Tina,
    You can use a trnasactions like SCMP, SADJ or SCU0 - all tools to do comparison of customizing objects across clients/systems using RFC.
    Details of these tools, their usage and functionalities are available in the Help Portal -
    [http://help.sap.com/saphelp_47x200/helpdata/en/70/1accb7fab511d18e0f0000e8a48612/frameset.htm]
    Best Regards,
    Rekha

  • Single record in query are splitted inot two record after creating the view

    HI ,
           We have created one query and when we execute with characteristics combinations we get some record.
           we have created the view on the same query and when we execute the view ,the same record is splitted into 2 lines with some of the key figures are showing in one line and remainig are in other line.
    please suggest here.

    Look at your source data. Keep in mind that your queries are just that.. queries. The number of rows of results is not a reflection of the number of database records you have in your infoprovide. It is what your query asked the infoprovider to give you.
    For example:
    You have two records. Both records have the same 'customer'. One record has document number "A", the other has document number "B". Record "A" has key figures Sales and Profit, Record "B" has key figures Quantity and Margin.
    Query 1 asks for Customer, Sales, and Margin. It will return both records A and B as one row of data, with the Sales data from record A, and the Margin data from record B
    Query 2 asks for Customer, Document number, Sales, and Margin. It will return two rows of data... the first showing record A and Sales but no margin, the second showing record B and Margin but no sales.

  • To compare two internal tables and delete records

    Hi friends,
        I have to compare two internal tables and should delete the records which is not present in both the tables. Reply me as soon as possible.
    Thanks.

    Hi Nagarajan,
    1. I don't think there is any direct (one-shot statement)
        way to achieve this.
        one has to do by writing some logic.
    2. Loop at ITAB1.
         Read table ITAB2 with key Field1 = ITAB1-Field1.
         If sy-subrc <> 0.
         delete ITAB1.
         endif.
       Endloop.
      Do the same again with ITAB2.
       Loop at ITAB2.
         Read table ITAB1 with key Field1 = ITAB2-Field1.
         If sy-subrc <> 0.
         delete ITAB2.
         endif.
       Endloop.
    3. If any better way is found, i will let u know.
    Hope it helps.
    Regards,
    Amit M.

  • Comparing Two tables with 300k records and update one table

    Could you let me know how to compare two tables having 300k records and update one table.below is the scenario.
    Table Tabl_1 has columns A,B and Tabl_2 has columns B,new_column.
    Column B has same data in both the tables.
    I need to update Tabl_2 in new_column with Tabl_1 A column data by comparing B column in both tables.
    I m trying to do using PLSQL Tables.
    Any suggestion?
    Thanks.

    Hi,
    Whenever you have a problem, please post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) from all tables involved, so that the people who want to help you can re-create the problem and test their ideas.
    Also post the results you want from that data, and an explanation of how you get those results from that data, with specific examples.
    If you're asking about a DML statement, such as UPDATE, the CREATE TABLE and INSERT statements should re-create the tables as they are before the DML, and the results  will be the contents of the changed table(s) when everything is finished.
    Always say which version of Oracle you're using (for example, 11.2.0.2.0).
    See the forum FAQ: https://forums.oracle.com/message/9362002
    ef2019c7-080c-4475-9cf4-2cf1b1057a41 wrote:
    Could you let me know how to compare two tables having 300k records and update one table.below is the scenario.
    Table Tabl_1 has columns A,B and Tabl_2 has columns B,new_column.
    Column B has same data in both the tables.
    I need to update Tabl_2 in new_column with Tabl_1 A column data by comparing B column in both tables.
    I m trying to do using PLSQL Tables.
    Any suggestion?
    Thanks.
    Why are you trying to use PL/SQL tables?  If tabl_1 and tabl_2 are regular database tables, it will be much simpler and faster just to use them.
    Depending on your requirements, you can do an UPDATE or MERGE, either in SQL or in PL/SQL.

  • Multiple UNION ALL views within a view returning incorrect records?

    Hi,
    I have a view which selects from multiple views with UNION ALL joining them. If I just select from the larg UNION ALL query I return more records (correct amount) than If I create a view, and select from it.
    e.g.
    SELECT *
    FROM vw_load_1
    UNION ALL
    SELECT *
    FROM vw_load_2
    UNION ALL
    SELECT *
    FROM vw_load_3
    UNION ALL
    SELECT *
    FROM vw_load_4
    UNION ALL
    SELECT *
    FROM vw_load_5
    Returns 405 Records
    but
    CREATE VIEW vw_master_load
    AS
    SELECT *
    FROM vw_load_1
    UNION ALL
    SELECT *
    FROM vw_load_2
    UNION ALL
    SELECT *
    FROM vw_load_3
    UNION ALL
    SELECT *
    FROM vw_load_4
    UNION ALL
    SELECT *
    FROM vw_load_5;
    SELECT COUNT(*)
    FROM vw_master_load
    Returns 307 records
    Can anyone explain why, or how to get around this?
    Oracle version: Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
    PL/SQL Release 11.2.0.2.0 - Production

    Hi,
    Are you saying that you run:
    select count(*) from (
      SELECT *
      FROM vw_load_1
      UNION ALL
      SELECT *
      FROM vw_load_2
      UNION ALL
      SELECT *
      FROM vw_load_3
      UNION ALL
      SELECT *
      FROM vw_load_4
      UNION ALL
      SELECT *
      FROM vw_load_5
    result is: 307 And then you run
      SELECT *
      FROM vw_load_1
      UNION ALL
      SELECT *
      FROM vw_load_2
      UNION ALL
      SELECT *
      FROM vw_load_3
      UNION ALL
      SELECT *
      FROM vw_load_4
      UNION ALL
      SELECT *
      FROM vw_load_5
    returns 405 rowsIf so, that is very strange.
    Can you an example we can re-produce?
    Regards,
    Peter

  • How can I compare two summary field in cross-tab?

    <p>Dear expert:</p><p>I have one question for how can I compare two summary field in cross-tab?  I have following cross-table:</p><p>Type          Sector1     Sector2    Sector3       Total </p><p>Outlook         10            11           9              30         </p><p>Target            5              3           1               9</p><p>I want to compare the summary field(total) relationship percent, I want to get "9/30". Someone told me I must create the DB view or table via SQL, then can implete in Crystal Report. Can I implete it in Crystal Report via fomula or other function?</p><p>Thanks so much for your warm-hearted help!</p><p>Steven</p>

    Hello Steven, yes you can compare summary fields, If you are comparing Summary to Target, or vice versa - you can do it within Crystal Reports.
    1. In Suppress conditional formula, create 2 Global variables: CurrentOutlook and CurrentTarger and get the current value.
    2. In Display String formula for Total show ToText(CurrentTarget/CurrentOUtlook) + "%".
    For more difficult cases of compariing fields in cross--tab, you may look into http://www.relasoft.net/KB10001.html.
    Best,
    Alexander

  • Record slideshow and view presenter view?

    Is it possible to have he presenter view while recording a narration to the slideshow? The default view when entering menu Record Slideshow... is the full slide view, without next slide and presenter comments.
    Message was edited by: petrush

    Hello Steve
    I may have misunderstood your question a littel and raced off and examined your site.  What you are saying is that your pages in Dreamweaver look different to the web and you have some content that is from an old version of the site?
    If that's the case, I'm wondering how you have set up the site in Dreamweaver?  When you set up an individual site you should define a site.  This helps dreamweaver manage various aspects of the site's structure.  Did you do anything like that?  Are you relying on an older copy of your site on your PC or did you install a completely fresh copy on your machine after the web designer's redesign?
    One thing that I would try is to compare a page that does look ok with a page that does not.  Identify the part of the page that doesn't look right and examine the two pages in code view to see if you can spot the difference.
    Apart from that, the validation errors are a different thing.  Your website is working and it looks pretty good and if that's your main concern that might be enough for you.
    In the mean time, let's hope someone with a bit more clout can come up with some suggestions!
    Martin

  • Use case for showing records in report view BAM based on version number

    Hi,
    I have a use case to update records based on version no. Let say I have a table or data object in BAM called 'Notes'. The Notes dataobject has three fields Id, Version, Description. The Notes data is displayed in a BAM report. I need to just display the latest version of the Notes. Say two records with one with Id as '124' and Version '4' and another with Id as '124' and version as '5'. The record related to version 5 should be dispalyed to user. How will I introduce this check in BAM reports for the latest version?
    Thanks
    Edited by: user5108636 on 28/06/2010 16:47

    That you see you're prints only means that your method outta called. The code creates a new row, but never inserts the row into the rowset. Then you call execute query which loses any connection to the new route which is not part of the rowset.
    First action would never to call insertRow(r1) on the view object.
    If you change data this way, only the model layer knows about it, the ui can't know about this (one of the disadvantages of using plsql or this construct you try). You have to tell the view controller to update it's data to. For this you can execute the iterator in the binding layer and/or ppr the container showing your data.
    Then I don't see any complicated plsql called do I question if a programmatic co is necessary.
    Timo

Maybe you are looking for

  • Calling RFC

    Hi Team, I am calling RFC fron ECC 6.0 to SAP 4.6c. Destination is maitained in SM59. Problem: When i am calling RFC through my report program. Sy-subrc is 1. When running FM at orginal destination it is working fine. Any helpful pointers...

  • Formula node with global variable

    Hi, I am tring to use formula node with global variables as an input and output, but this is where I see the SW hangs forever. By the way I am a novice to the labview. Can some give me hint why this is happening? Thank you in advance, Do Solved! Go t

  • Create lens profile for ultra wide angle lens

    Hello, I am trying to create a lens profile for the ultra wide angle lens Olympus 9-18 mm (Crop factor 2). As i use the lens for timelapse, i only need the profiles for 9 mm and open aperture f4, but combined with several different ND-filters which s

  • Pls help in Mapping org strucutre

    HI Gurus, Yesterday i got clarified some doubts on my clients mapping. I want somebody to explain even in detail please.Its is urgent. My Client is Pharmaceutical company with H.O. inmumbai.They ditribute the drugs through thier C&F(Carry & Forward)

  • HT201335 cannot get airplay icon to mirror mac on apple tv

    Does anyone know how to get the os mountain lion to recongnize the apple tv to do a mirror with the mac book air?