<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to compare two fields from the same table in the select statement in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-compare-two-fields-from-the-same-table-in-the-select-statement/m-p/7042565#M1500888</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The ABAP help is your friend, just do the F1 on the SELECT statement. Let me give you the jump start now, so you're prepared for the next time...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Look at the [SELECT|http://help.sap.com/abapdocu_70/en/ABAPSELECT.htm] statement, drill down into the [WHERE|http://help.sap.com/abapdocu_70/en/ABAPWHERE.htm] clause and then into the [sql_cond|http://help.sap.com/abapdocu_70/en/ABENWHERE_LOGEXP.htm]. There you'll see the following comment:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt;You can specify the same column names (comp, dbtab&lt;SUB&gt;comp, tabalias&lt;/SUB&gt;comp) for col  as are listed in the specification of single columns after SELECT.&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The SELECT statement you've listed is only syntactically correct, if you have defined a variable or table with name AUFK. Most likely the variable is initial and thus you're searching for entries with a blank creation date (and naturally none should exist). So change your query to this:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
select count(*) into cptotchek from aufk where erdat = aufk~idat2.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Note that for this single statement there's no need to define AUFK as a variable (via DATA or TABLES).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers, harald&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 17 Jul 2010 12:00:32 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2010-07-17T12:00:32Z</dc:date>
    <item>
      <title>How to compare two fields from the same table in the select statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-compare-two-fields-from-the-same-table-in-the-select-statement/m-p/7042563#M1500886</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, friends &lt;/P&gt;&lt;P&gt;I try to compare tow fields from the same table, but no result, &lt;/P&gt;&lt;P&gt;For example, this &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data: cptotchek tyep i.&lt;/P&gt;&lt;P&gt;select count(*) into cptotchek&lt;/P&gt;&lt;P&gt;from aufk where erdat = aufk-idat2 .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The result is  cptotchek = 0, but there are the records in aufk , where,  aufk-erdat = aufk-idat2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please, help me, i don't use the loop statement for optimize my program.&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 17 Jul 2010 07:43:25 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-compare-two-fields-from-the-same-table-in-the-select-statement/m-p/7042563#M1500886</guid>
      <dc:creator>former_member215254</dc:creator>
      <dc:date>2010-07-17T07:43:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare two fields from the same table in the select statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-compare-two-fields-from-the-same-table-in-the-select-statement/m-p/7042564#M1500887</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi  ,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;       it will not return  any value   when you are using   column of same table  &lt;/P&gt;&lt;P&gt;       such as Date Field   , Because  while Using Aggregate Function  it will not check with self column &lt;/P&gt;&lt;P&gt;.      For that you have to take data in one internal table and then you can work on it  .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;     And if you are worried about Performance  it will not affect  , untill you are selecting only required data  .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; you can try this way  .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data: cptotchek type i.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;types : begin of  w_aufk.&lt;/P&gt;&lt;P&gt;        include structure aufk  .&lt;/P&gt;&lt;P&gt;      types : end of  w_aufk .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data : it_aufk type standard table of w_aufk with header line  .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select * into corresponding fields of table it_aufk&lt;/P&gt;&lt;P&gt;from aufk  .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; loop at it_aufk .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; if it_aufk-erdat  = it_aufk-idat2 .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; write : / it_aufk-erdat , it_aufk-idat2 .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; else .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; delete it_aufk .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; endif  .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Deepak.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 17 Jul 2010 10:45:13 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-compare-two-fields-from-the-same-table-in-the-select-statement/m-p/7042564#M1500887</guid>
      <dc:creator>deepak_dhamat</dc:creator>
      <dc:date>2010-07-17T10:45:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare two fields from the same table in the select statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-compare-two-fields-from-the-same-table-in-the-select-statement/m-p/7042565#M1500888</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The ABAP help is your friend, just do the F1 on the SELECT statement. Let me give you the jump start now, so you're prepared for the next time...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Look at the [SELECT|http://help.sap.com/abapdocu_70/en/ABAPSELECT.htm] statement, drill down into the [WHERE|http://help.sap.com/abapdocu_70/en/ABAPWHERE.htm] clause and then into the [sql_cond|http://help.sap.com/abapdocu_70/en/ABENWHERE_LOGEXP.htm]. There you'll see the following comment:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt;You can specify the same column names (comp, dbtab&lt;SUB&gt;comp, tabalias&lt;/SUB&gt;comp) for col  as are listed in the specification of single columns after SELECT.&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The SELECT statement you've listed is only syntactically correct, if you have defined a variable or table with name AUFK. Most likely the variable is initial and thus you're searching for entries with a blank creation date (and naturally none should exist). So change your query to this:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
select count(*) into cptotchek from aufk where erdat = aufk~idat2.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Note that for this single statement there's no need to define AUFK as a variable (via DATA or TABLES).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers, harald&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 17 Jul 2010 12:00:32 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-compare-two-fields-from-the-same-table-in-the-select-statement/m-p/7042565#M1500888</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-07-17T12:00:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare two fields from the same table in the select statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-compare-two-fields-from-the-same-table-in-the-select-statement/m-p/7042566#M1500889</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thinks, problem solved, as the last's answer.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select count(*) into cptotchek from aufk where erdat = aufk~idat2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards again.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 17 Jul 2010 14:32:58 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-compare-two-fields-from-the-same-table-in-the-select-statement/m-p/7042566#M1500889</guid>
      <dc:creator>former_member215254</dc:creator>
      <dc:date>2010-07-17T14:32:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare two fields from the same table in the select statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-compare-two-fields-from-the-same-table-in-the-select-statement/m-p/7042567#M1500890</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thinks, problem solved, as the last's answer.&lt;/P&gt;&lt;P&gt;select count(*) into cptotchek from aufk where erdat = aufk~idat2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards again. Youu2019re the best.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 17 Jul 2010 14:33:41 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-compare-two-fields-from-the-same-table-in-the-select-statement/m-p/7042567#M1500890</guid>
      <dc:creator>former_member215254</dc:creator>
      <dc:date>2010-07-17T14:33:41Z</dc:date>
    </item>
  </channel>
</rss>

