<?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 Select Query using table aliasing in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-query-using-table-aliasing/m-p/8115944#M1617969</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I have 2 select queries as below.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to AVOID hitting the EVER table twice .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;get all the contracts &amp;amp; CA for the Move Out date from EVER.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;1) select * from ever into table it_ever&lt;/P&gt;&lt;P&gt;where auszdat in s_modate.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2) if not it_ever is initial.&lt;/P&gt;&lt;P&gt;select * from dfkkop into table it_dfkkop&lt;/P&gt;&lt;P&gt;for all entries in it_ever[]&lt;/P&gt;&lt;P&gt;where hvorg = '0200'&lt;/P&gt;&lt;P&gt;and tvorg = '0002'&lt;/P&gt;&lt;P&gt;and vkont = it_ever-vkonto. "s_vkont&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;and augst ne '9'&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;and vtref = it_ever-contr1.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3) if it_dfkkop[] is not initial.&lt;/P&gt;&lt;P&gt;select * from ever into table it_ever1&lt;/P&gt;&lt;P&gt;for all entries in it_dfkkop&lt;/P&gt;&lt;P&gt;where vkonto = it_dfkkop-vkont&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;and einzdat ge sy-datum "commented temporarily&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;and auszdat gt sy-datum.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can anyone suggest me to combine 1) &amp;amp; 3) into one select query. Probably we need to use table aliasing which i dont know.&lt;/P&gt;&lt;P&gt;Sorry that i dont know how to use code tags&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Ricky&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 19 Aug 2011 14:06:21 GMT</pubDate>
    <dc:creator>ricky_shaw</dc:creator>
    <dc:date>2011-08-19T14:06:21Z</dc:date>
    <item>
      <title>Select Query using table aliasing</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-query-using-table-aliasing/m-p/8115944#M1617969</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I have 2 select queries as below.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to AVOID hitting the EVER table twice .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;get all the contracts &amp;amp; CA for the Move Out date from EVER.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;1) select * from ever into table it_ever&lt;/P&gt;&lt;P&gt;where auszdat in s_modate.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2) if not it_ever is initial.&lt;/P&gt;&lt;P&gt;select * from dfkkop into table it_dfkkop&lt;/P&gt;&lt;P&gt;for all entries in it_ever[]&lt;/P&gt;&lt;P&gt;where hvorg = '0200'&lt;/P&gt;&lt;P&gt;and tvorg = '0002'&lt;/P&gt;&lt;P&gt;and vkont = it_ever-vkonto. "s_vkont&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;and augst ne '9'&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;and vtref = it_ever-contr1.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3) if it_dfkkop[] is not initial.&lt;/P&gt;&lt;P&gt;select * from ever into table it_ever1&lt;/P&gt;&lt;P&gt;for all entries in it_dfkkop&lt;/P&gt;&lt;P&gt;where vkonto = it_dfkkop-vkont&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;and einzdat ge sy-datum "commented temporarily&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;and auszdat gt sy-datum.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can anyone suggest me to combine 1) &amp;amp; 3) into one select query. Probably we need to use table aliasing which i dont know.&lt;/P&gt;&lt;P&gt;Sorry that i dont know how to use code tags&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Ricky&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 19 Aug 2011 14:06:21 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-query-using-table-aliasing/m-p/8115944#M1617969</guid>
      <dc:creator>ricky_shaw</dc:creator>
      <dc:date>2011-08-19T14:06:21Z</dc:date>
    </item>
    <item>
      <title>Re: Select Query using table aliasing</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-query-using-table-aliasing/m-p/8115945#M1617970</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Ricky,&lt;/P&gt;&lt;P&gt;I don't think you have to combine 1 and 3. You just need to replace the 3 by a LOOP AT / DELETE to remove all entries of IT_EVER that do not have a corresponding entry in IT_DFKKOP.&lt;/P&gt;&lt;P&gt;Sandra&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 19 Aug 2011 16:28:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-query-using-table-aliasing/m-p/8115945#M1617970</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2011-08-19T16:28:07Z</dc:date>
    </item>
    <item>
      <title>Re: Select Query using table aliasing</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-query-using-table-aliasing/m-p/8115946#M1617971</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In my opinion an inner join can do that work also...just trying to combine 1 to 3...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;select * into table it_ever 
from ever as i
 inner join dfkkop as d
on i~vkont = d-vkonto
where i~auszdat in s_modate
     and d~hvorg = '0200'
     and d~d!tvorg = '0002'.

if sy-subrc eq 0.
 delete it_ever where auszdat gt sy-datum.
endif.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can you please try this?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 19 Aug 2011 21:07:51 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-query-using-table-aliasing/m-p/8115946#M1617971</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-08-19T21:07:51Z</dc:date>
    </item>
    <item>
      <title>Re: Select Query using table aliasing</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-query-using-table-aliasing/m-p/8115947#M1617972</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Ricky,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the task is &lt;STRONG&gt;not&lt;/STRONG&gt;  the tables, the task is to identify which fields you need from which table&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;select dfkkop~gpart dfkkop~vkont dfkkop~bukrs dfkkop~betrw ... ever~einzdat ever~auszdat...
  into corresponding fields of table &amp;lt;your result table&amp;gt;
   from dfkkop 
  join ever
    on ever~contr1 = dfkkkop~vtref and 
       ever~vkonto =  dfkkkop~vkont
   where hvorg = '0200'
     and tvorg = '0002'
     and ever~einzdat ge sy-datum "commented temporarily
     and ever~auszdat gt sy-datum.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Don't worry about code tags: Select the code with the mouse and hit the &amp;amp;lt;&amp;amp;gt; button above. Or write  before and after the code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Clemens&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 19 Aug 2011 22:39:26 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-query-using-table-aliasing/m-p/8115947#M1617972</guid>
      <dc:creator>Clemenss</dc:creator>
      <dc:date>2011-08-19T22:39:26Z</dc:date>
    </item>
    <item>
      <title>Re: Select Query using table aliasing</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-query-using-table-aliasing/m-p/8115948#M1617973</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;Thanks for the replies . But what i want to ask you is that:&lt;/P&gt;&lt;P&gt;fact :  Generally, a VKONT in table DFKKOP has more entries contracts in EVER table.&lt;/P&gt;&lt;P&gt;1) I need to first get all the VKONTs(Contract Accounts) &amp;amp; Vertrags (Contracts) from EVER table.&lt;/P&gt;&lt;P&gt;2) And then based above fact i will get all Contracts in EVER after passing the VKONT (which we got from EVER).&lt;/P&gt;&lt;P&gt;3) So i want to know if i can write some Table Aliasing while hitting DFKKOP itself (as below) to avoid a second query for EVER table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt; select a~vkont a~vtref a~betrh from dfkkop into table it_dfkkop
for all entries in it_ever[]
where hvorg = '0200'
and tvorg = '0002'
and vkont = it_ever-vkonto. "s_vkont
 and augst ne '9'
 and a~vkont = it_ever-contr1. --&amp;gt; can i write like this
endif.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i want to include the result set again as a source for where condition. Hope i am clear. This is possible using table aliasing but i do not know aout that.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Pls suggest.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Ricky&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Aug 2011 21:01:30 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-query-using-table-aliasing/m-p/8115948#M1617973</guid>
      <dc:creator>ricky_shaw</dc:creator>
      <dc:date>2011-08-23T21:01:30Z</dc:date>
    </item>
    <item>
      <title>Re: Select Query using table aliasing</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-query-using-table-aliasing/m-p/8115949#M1617974</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;just do the inner join between these two tables, with condition &lt;/P&gt;&lt;P&gt;ever-vkonto = dfkkop-vkont &lt;/P&gt;&lt;P&gt;ever-vkont  =  dfkkop-vkont &lt;/P&gt;&lt;P&gt;where  ever-auszdat in s_modate&lt;/P&gt;&lt;P&gt;   and    dfkkop-hvorg = '0200'&lt;/P&gt;&lt;P&gt;   and     dfkkop-tvorg = '0002'&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;then from the internal table delete records where  auszdat gt sy-datum.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This solve your problem in one select. No need to do three select.&lt;/P&gt;&lt;P&gt;N.B: Please check the performance.(some times three select are much faster than one select with join condition)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Subhankar&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 24 Aug 2011 04:13:14 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-query-using-table-aliasing/m-p/8115949#M1617974</guid>
      <dc:creator>Subhankar</dc:creator>
      <dc:date>2011-08-24T04:13:14Z</dc:date>
    </item>
  </channel>
</rss>

