How to compare two fields from the same table in the select statement

Hi, friends
I try to compare tow fields from the same table, but no result,
For example, this
data: cptotchek tyep i.
select count(*) into cptotchek
from aufk where erdat = aufk-idat2 .
The result is  cptotchek = 0, but there are the records in aufk , where,  aufk-erdat = aufk-idat2.
Please, help me, i don't use the loop statement for optimize my program.
Regards

Hi  ,
       it will not return  any value   when you are using   column of same table 
       such as Date Field   , Because  while Using Aggregate Function  it will not check with self column
.      For that you have to take data in one internal table and then you can work on it  .
     And if you are worried about Performance  it will not affect  , untill you are selecting only required data  .
you can try this way  .
data: cptotchek type i.
types : begin of  w_aufk.
        include structure aufk  .
      types : end of  w_aufk .
data : it_aufk type standard table of w_aufk with header line  .
select * into corresponding fields of table it_aufk
from aufk  .
loop at it_aufk .
if it_aufk-erdat  = it_aufk-idat2 .
write : / it_aufk-erdat , it_aufk-idat2 .
else .
delete it_aufk .
endif  .
endloop.
Regards
Deepak.

Similar Messages

  • How to compare two fields from different list sharepoint designer?

    hi All,
    I need to add a value to a field using SharePoint designer workflow. The value is from another column.
    for example list A has the field has loginID,  and another list B has loginID  amd another column called Desig.
    i need to compare both and get the Desig field and store it to a column. how do i do that in sharePoint Designer workflow.

    Hi, 
    you can create a workflow variable ex.Test. and add an action set Workflow variable. Then you have to set this variable value using lookUps. something like(in look up window)
    Data source: Choose List B
    Field from source: Choose Desig
    Then under find the list item
    Field: Choose login Id
    Value :(Again open lookup window by clicking "fx") and in this window choose 
        data Source: List A
      field from source :LoginId
    and click ok.
    attached is the image for your reference. (I am using other lists,you can change appropriately )

  • How to compare two fields from two different groups

    My RTF template is like this.
    GROUP A
    Field 1 Field 2 Field 3 (Display in table)
    GROUP B
    **Condition
    Display Fields from B
    end GROUP B
    end GROUP A
    But I need the following condition to be added at the place (** Condition)
    IF A.Field1 = B.Field1
    Display fields from B
    END IF
    end Group B
    end Group A
    Please help, if anyone has come across such a situation.
    Thanks,
    Anand

    You can use variables to store the A.field1 value and then compare it against B.Field1.
    Take a look at this post for an example: https://blogs.oracle.com/xmlpublisher/entry/formatting_concatenated_dataso
    Thanks,
    Bipuser

  • How to compare two rows from two table with different data

    how to compare two rows from two table with different data
    e.g.
    Table 1
    ID   DESC
    1     aaa
    2     bbb
    3     ccc
    Table 2
    ID   DESC
    1     aaa
    2     xxx
    3     ccc
    Result
    2

    Create
    table tab1(ID
    int ,DE char(10))
    Create
    table tab2(ID
    int ,DE char(10))
    Insert
    into tab1 Values
    (1,'aaa')
    Insert
    into tab1  Values
    (2,'bbb')
    Insert
    into tab1 Values(3,'ccc')
    Insert
    into tab1 Values(4,'dfe')
    Insert
    into tab2 Values
    (1,'aaa')
    Insert
    into tab2  Values
    (2,'xx')
    Insert
    into tab2 Values(3,'ccc')
    Insert
    into tab2 Values(6,'wdr')
    SELECT 
    tab1.ID,tab2.ID
    As T2 from tab1
    FULL
    join tab2 on tab1.ID
    = tab2.ID  
    WHERE
    BINARY_CHECKSUM(tab1.ID,tab1.DE)
    <> BINARY_CHECKSUM(tab2.ID,tab2.DE)
    OR tab1.ID
    IS NULL
    OR 
    tab2.ID IS
    NULL
    ID column considered as a primary Key
    Apart from different record,Above query populate missing record in both tables.
    Result Set
    ID ID 
    2  2
    4 NULL
    NULL 6
    ganeshk

  • Compare two rows in a same table

    Dear all
    I need to compare two rows in the same table, I dont know hoe to do it in pl/sql. Some one please help me on this.
    example:
    tr br price
    xya0001 ama7 12
    xya0003 ama6 14
    xya0004 ama7 16
    in the table tr is a unique value for each row, I need to compare price column and see whether the first value is less or greater than the next value and, if it is greater put the corresponding br value to a variable and if it is smaller put the corresponding br value to another variable. I dont know a method to do it, as I'm new to pl/sql. Some one please help me in this

    not sure what you intend to do as you have mentioned that "TR" is unique and you just want to compare each record with just the next record. Hope below query helps. The value "G" or "L" in flag would indicate if the current records price is greater than or less than the price in next record.
    select tr,br,price,col4, case when price> col4 then 'G'  when price< col4 then 'L' end flag from (
    select tr,br,price,lag(price,1,0) over(order by tr) col4 from testcomp
    )

  • For the same table in the same page, how to use 2 different forms (simple and tabular)?

    Hello! How I can be on the same page with the same table insert and update operations using 2 different forms (single form and tabular form)
    I have little knowledge of Apex, but I know PLSQL
    Thanks
    Ginger
    Ecuador

    Thank you Gramps.  It took some time, but I've got it working now.  I had to re-do all the user authentication actions from scratch for one of the databases, but it's finally behaving itself now.  I appreciate you pointing me in the right direction.

  • Problem with the sames tables in the same report

    Hi friends,
             I have a report with the same table twice. One with the original name (Company) and the second with alias (Company_A). This report wants to show a "tree" of companies. With code I get a Dataset    and I fill the report with it. This Dataset    have two tables the original and the alias table with one and two rows expletively. The data is correct is what we expect that the report will show but this not occurs. He only see the rows of the original table and if you get more than one row in it he try a Cartesian product and we see invalid results. Can I fill the report with the correct rows to show in the report? Is there any other possibility? To help I put an example:
    Fields of table Company as original table in the report: Company.
    Fields of table Company as alias table (Company_A) in the report: Company and OriginCompany.
    There is a relation between Company and Company_A through the field Company (original alias) and OriginCompany (alias table).
    The dataset    is like this:
    Table Company: one row --> Company1.
    Table Company_A: two rows --> Company1a, Company.
                                                   Company2a, Company.
    Then the report only shows the rows of the original table Company but no trace of the alias table Company_A
    If someone can help me thanks and if not also!!!
    Edited by: JuliaRomero on Jun 1, 2009 4:30 PM

    Use two connections not one when you are embedding one result set in another.
    If you are embedding one in the other also consider using a join which is faster and requires less code.

  • How to summary a field from 2 separate tables but having the same fields

    Post Author: thuyvd78
    CA Forum: General
    Hi, I am getting trouble with creating the summary from 2 separate tables. These tables dont have any link together but they have the same fields, such as: part id, qty, etc. I need to create a report that displays whole the information from these tables and also the summary of total qty field of these tablesAny idea to organize this report? Thank you very much! Thuy  

    Post Author: thuyvd78
    CA Forum: General
    Thank you for your help v361.where can I can get the link to download samples for subreport from official website?And can I use FULL INNER query to join these tables. I think this way is much clearer than using subreport but not sure it will work? Thanks Thuy  

  • How to compare two rows in PL/SQL and retrieve the values?

    Hello,
    I have two tables which have identical schemas, one table (tbl_store) is used to hold the latest version, and the other table (tbl_store_audit) holds previous versions. When the latest record is updated, it is inserted into the tbl_store_audit table as a revision, and the updated details are used as the latest record.
    For example: The latest version is held in tbl_store, however the tbl_store_audit may hold 5 records which are the past records used before changes were made - these are seen as revisions.
    I want to be able to compare what has changed between each revision in the tbl_store_audit table. For example: Out of the 10 columns, the change between revision 1 and revision 2 was the size from XL to XXL. The change between revision 3 and revision 4 was the size XS to M and price 4.99 to 10.99, and so on.
    Eventually i will create an APEX report that will show the user the revision number and what was changed from and to.
    I seen in a previous post i need to note my oracle version: Oracle version 10.2.0.4.0

    Hi,
    Like suggested already you should give some sample data and output.
    Maybe you would like to have something like this:
    -- Sample data
    -- Note PK is the primairy key of the source table and rev are the revisions
    with tbl_store_audit as
    select 1 pk, 1 rev , 1 price  , 'XXL' unit_size from dual union all
    select 1 pk, 2 rev , 1 price,   'XL'  unit_size from dual union all
    select 1 pk, 3 rev , 1.4 price, 'XXL' unit_size from dual union all
    select 2 pk, 1 rev , 1.4 price, 'XL'  unit_size from dual union all
    select 2 pk, 2 rev , 1.4 price, 'XL'  unit_size from dual union all
    select 2 pk, 3 rev , 1.4 price, 'XL'  unit_size from dual union all
    select 1 pk, 4 rev , 1 price  , 'XL'  unit_size from dual union all
    select 1 pk, 5 rev , 1 price  , 'XL'  unit_size from dual union all
    select 3 pk, 1 rev , 1.2 price, 'XL'  unit_size from dual union all
    select 3 pk, 2 rev , 1.2 price, 'XXL' unit_size from dual union all
    select 4 pk, 1 rev , 1 price  , 'XL'  unit_size from dual
    -- end of sample data
    ,tbl_store_audit_tmp as
    select
      pk
      ,rev
      ,'PRICE'          field_name
      ,to_char(price)   field_value
      ,to_char(lag(price,1) over (partition by pk order by rev) ) old_field_value
    from
      tbl_store_audit
    union all
    select
      pk
      ,rev
      ,'UNIT_SIZE'           field_name
      ,to_char(UNIT_SIZE)    field_value
      ,to_char(lag(UNIT_SIZE,1) over (partition by pk order by rev) ) old_field_value
    from
      tbl_store_audit
    -- include all other fields from the table here with it's own union all select ...
    select
    from
      tbl_store_audit_tmp
    where
      field_value != old_field_value
    PK REV FIELD_NAME FIELD_VALUE                              OLD_FIELD_VALUE                       
    1   3 PRICE      1.4                                      1                                       
    1   4 PRICE      1                                        1.4                                     
    1   2 UNIT_SIZE  XL                                       XXL                                     
    1   3 UNIT_SIZE  XXL                                      XL                                      
    1   4 UNIT_SIZE  XL                                       XXL                                     
    3   2 UNIT_SIZE  XXL                                      XL                                      
    6 rows selected If you realy want to keep track of all the changes I think it would be better if you make a "after update trigger" on the base table that checks what changed and put that directly in the uadit table.
    Regards,
    Peter
    Edited by: Peter vd Zwan on Aug 16, 2012 8:25 AM

  • How to compare two fields in condition editor in receiver determination

    Hello,
    Is it possible to compare to fields frrom the source in the condition editor of Receiver Determination?
    Because on the right hand operand we can specify only constants right and not the source field.
    For eg: If field1 != field2 then Reciever =  Receiver1
    Thanks,
    Loveena

    In standard receiver determination while defining the condition, you can only specify an element from the message payload using expression editor to create an expression for the left operand and you must specify a fixed value in the right operand, against which the value of the element will be compared at runtime. You can use only these (=,, ,EX) operators. So the functionalities are limited.
    so you have to use Enhanced Receiver Determination, In this Instead of creating the receivers in the receiver determination manually, you assign an Interface mapping to the receiver determination and this returns a list of receivers at runtime.
    refer this wiki for more details
    http://wiki.sdn.sap.com/wiki/pages/viewpage.action?pageId=133562771

  • How to compare two fields in two seperate databases

    Hi
    Can we compare two columns in two separate databases with a one script.
    Cheers
    Shabar

    Hi,
    if you mean Oracle to sqlserver then you would have to put hand in pocket and buy ODBC connectivity for this...
    If it is just a one off maybe export your data and import into Oracle table and do your one off comparision.
    regards,
    Robert.

  • Pseudorandom number generation based upon an integer seed,to produce the same table given the same seed.

    Does LabVIEW have a VI that produces Pseudorandom
    Numbers based upon supplying a integer Seed Value? This way
    you could generate a table of numbers that looked random, but
    could be reproduced for test comparisons whenever you
    supplied the same seed value. Do such algorhythms
    already exist in the liabrary somewhere?
    Larry

    It may be that even these subVIs might not do quite the trick depending on what you want. If you want to get exactly the same random number (or array) from the Gaussian White Noise.vi for example, you may need to edit the VI and create a personalized copy.
    In the existing VI, the seed value that you input as a parameter is actually 'randomized' on the first run of the program (open the VI and look at the case statement inside the loop). If you want the same seed to always kick off the same set of random numbers (for re-testing at a later time) you'll definitely want to take that code out. It is as easy as moving the two cluster constants outside the while loop (as initial values of the shift registers) and deleting the rest of the case (and re-attaching the
    broken wires), so it's not too bad at all.
    Cheers,
    EMR
    Cheers,
    Elaine R.
    www.bloomy.com

  • How to add a field from BSAK/BSIK table in FI_AP_4 Data source

    Hi Experts.
    I need to add a field in FI_AP_4 data source.
    Can you provide me steps in detail to do so, any sample for ABAP code too. field name is XZAHL and it is in multiple tables.
    Thanks
    mihameed

    hi Amams
    check this link
    Adding Fields to Sales order
    i think it may give u some idea
    Regards,
    Naveen

  • Calculating average time from two records from the same table.

    Hi all
    I need to calculate the average time between two events that are recorded in the same table.
    The table is TMS_MESSAGE_AUDIT_LOG
    MESSAGE_ID VARCHAR2(16 BYTE) NOT NULL,
    MESSAGE_VERSION NUMBER(2) NOT NULL,
    CREATE_TM VARCHAR2(18 BYTE) NOT NULL,
    MESSAGE_STATUS VARCHAR2(30 BYTE),
    TRANSACTION_TYPE_NM VARCHAR2(30 BYTE),
    MESSAGE_TP VARCHAR2(3 BYTE),
    WORKFLOW_OBJECT VARCHAR2(30 BYTE) NOT NULL,
    WORKFLOW_REQUEST VARCHAR2(30 BYTE) NOT NULL,
    WORKFLOW_RETURN_CD VARCHAR2(30 BYTE) NOT NULL,
    AUDIT_ACTION VARCHAR2(255 BYTE),
    LAST_UPDATE_USER_LOGON_ID VARCHAR2(12 BYTE),
    LOCAL_TM VARCHAR2(18 BYTE) NOT NULL,
    LOCAL_TIME_ZN_NM VARCHAR2(70 BYTE) NOT NULL,
    LOCAL_DAYLIGHT_IN CHAR(1 BYTE) NOT NULL,
    FPRINT VARCHAR2(30 BYTE)
    What i now need is
    When the MESSAGE_ID is the same i need have the average time between when the MESSAGE_STATUS is AA and BB ( I need the time out of the CREATE_TM field )
    And this for every 15 minutes interval.
    Because this table will become BIG millions and millions of records it needs to be fast.
    Can anybody help me.
    Marcel

    Something like this?
    CREATE TABLE wr_test
    ( message_id                 VARCHAR2(16 BYTE) NOT NULL
    , message_version            NUMBER(2) NOT NULL  -- Assumption: Acknowledged ver > Received ver
    , create_tm                  VARCHAR2(18 BYTE) NOT NULL
    , message_status             VARCHAR2(30 BYTE)
    , transaction_type_nm        VARCHAR2(30 BYTE)
    , workflow_object            VARCHAR2(30 BYTE) DEFAULT 'x' NOT NULL
    , workflow_request           VARCHAR2(30 BYTE) DEFAULT 'x' NOT NULL
    , workflow_return_cd         VARCHAR2(30 BYTE) DEFAULT 'x' NOT NULL
    , audit_action               VARCHAR2(255 BYTE)
    , last_update_user_logon_id  VARCHAR2(12 BYTE)
    , local_tm                   VARCHAR2(18 BYTE) NOT NULL
    , local_time_zn_nm           VARCHAR2(70 BYTE) DEFAULT 'GMT' NOT NULL
    , local_daylight_in          CHAR(1 BYTE) DEFAULT 'x' NOT NULL );
    INSERT ALL
    INTO   wr_test
           ( message_id
           , message_version
           , create_tm
           , message_status
           , local_tm )
    VALUES ( message_id
           , 1
           , create_tm
           , '(Receive)'
           , TO_CHAR(local_tm,'YYYYMMDD HH24:MI:SS') )
    INTO   wr_test
           ( message_id
           , message_version
           , create_tm
           , message_status
           , local_tm )
    VALUES ( message_id
           , 2
           , create_tm
           , 'Wait CLSB Ack'
         , TO_CHAR
           ( local_tm + NUMTODSINTERVAL(DBMS_RANDOM.VALUE(0,2e5),'SECOND')
           , 'YYYYMMDD HH24:MI:SS' ) )
    SELECT ROWNUM AS message_id
         , TO_CHAR(SYSDATE,'YYYYMMDD HH24:MI:SS') AS create_tm
         , DATE '2000-01-01' + DBMS_RANDOM.VALUE(0,3) AS local_tm
    FROM dual CONNECT BY ROWNUM < 100000;
    WITH src AS
         ( SELECT message_id
                , message_status
                , message_version
                , TO_DATE(SUBSTR(local_tm,1,17),'YYYYMMDD HH24:MI:SS') AS dt
                , TO_DATE(SUBSTR(local_tm,1,8),'YYYYMMDD') AS dt_day
                , TO_CHAR(TO_DATE(SUBSTR(local_tm,10,8),'HH24:MI:SS'),'SSSSS') AS dt_sec
           FROM   wr_test
           WHERE  message_status IN ('(Receive)','Wait CLSB Ack') )
    SELECT dt_day + NUMTODSINTERVAL(period,'SECOND') AS dt
         , NUMTODSINTERVAL(AVG(elapsed),'DAY') AS avg_elapsed
         , NUMTODSINTERVAL(MIN(elapsed),'DAY') AS min_elapsed
         , NUMTODSINTERVAL(MAX(elapsed),'DAY') AS max_elapsed
         , COUNT(*)
    FROM   ( SELECT message_id
                  , message_status
                  , dt_day
                  , TRUNC(dt_sec/300)*300 AS period
                  , LEAD(dt) OVER (PARTITION BY message_id ORDER BY message_version) AS ack_dt
                  , LEAD(dt) OVER (PARTITION BY message_id ORDER BY message_version) - dt AS elapsed
             FROM   src ) cal
    WHERE  cal.message_status = '(Receive)'
    GROUP BY dt_day, period
    ORDER BY 1;Replace "wr_test" with "tms_message_audit_log" in the WITH subquery to test on your data.

  • How to compare two files using MD5?

    Hi,all:
    How to compare two files to know if they're the same without any difference?I want to use MD5, but I just konw how get a message digest of a string. How to get a message digest of a file? Or there is other method to compare two files?
    Thanks advance!

    This is starting to sound rather a lot like a homework problem.
    An MD5 message digest is simply a 16 byte array. To compare two message digests...
    byte[] md5incoming = ...
    byte[] md5comparison = ...
    if( md5incoming.equals(md5comparison) ) {
       System.out.println("MD5 Checksums match");
    }To find out how to generate an MD5 checksum, please look up MessageDigest in the API documentation, and do a google search for "MD5 java"
    In a networked scenario, there are two issues - firstly the performance in sending copies of files all over the place (imagine if it's a 10Gb file to be compared over a 14.4K modem link, this would take a while). Secondly, the network link itself might insert an error in the file and you'd get a false miss.
    By only sending MD5 digests over the link, you simultaneously reduce the error (shorter files are less likely to be corrupted) and reduce the transmission time (16 bytes takes practically no time to transmit over damp string, let alone any sort of sensible device).
    D.

Maybe you are looking for

  • Exception message for PrdOrd and Planned order

    Hi Gurus, It possible based on prdord and planned ord we need to get the Exception message information. It's there any standard transaction code or any sqvi report? Note: Exception Message: 10 - Reschedule in 20 - cancel 05 - Opening date in the past

  • Flash player not loading videos after firefox update to 32.0.1

    Hi, I use Firefox portable and use it for work. I do moderation of videos. I open a page with 5-20 videos that load with Flash Player and view them. Today there was a Firefox update to 32.0.1 version. After update when I open a page I only get 1 vide

  • Problem with ABAP QUERY LDB

    Hi to all, I am using LDB for ABAP Query. For this I given selection fields. I don't want selection screen as like standard one. Ex. For QM11 transaction what ever screen appering like that my query smae appering . Please give solution for this. I wa

  • Deinstall Oracle 9i

    I want to deinstall Oracle 9i and install a fresh copy again. I deinstalled Oracle 9i, but when i run the installation again, i get a message again saying that a service with the same name already exists. I read in this forum that i have to delete th

  • Calling BSP's from SCM ICH

    Hello all, i need some information about calling BSP's from SCM ICH(inventory collaboration hub) into EP. for this what steps i need to do. pl suggest me thx pradeep