<?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 Using order by in the select query in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/using-order-by-in-the-select-query/m-p/1960675#M394976</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;&lt;/P&gt;&lt;P&gt;I have query in which I need the latest record. To get the latest record, I can&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1) Select all entries into an internal table and sort them descending and get the first one&lt;/P&gt;&lt;P&gt;2) Select all entries into an internal table and order by in the select statement itself.&lt;/P&gt;&lt;P&gt; Then read the first one.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Which approach should be better as for as the performance is concern.&lt;/P&gt;&lt;P&gt;The query is on MKPF table and I have the material document number. I need the latest entry.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Shahu&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 28 Feb 2007 10:19:34 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2007-02-28T10:19:34Z</dc:date>
    <item>
      <title>Using order by in the select query</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/using-order-by-in-the-select-query/m-p/1960675#M394976</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;&lt;/P&gt;&lt;P&gt;I have query in which I need the latest record. To get the latest record, I can&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1) Select all entries into an internal table and sort them descending and get the first one&lt;/P&gt;&lt;P&gt;2) Select all entries into an internal table and order by in the select statement itself.&lt;/P&gt;&lt;P&gt; Then read the first one.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Which approach should be better as for as the performance is concern.&lt;/P&gt;&lt;P&gt;The query is on MKPF table and I have the material document number. I need the latest entry.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Shahu&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 28 Feb 2007 10:19:34 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/using-order-by-in-the-select-query/m-p/1960675#M394976</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-02-28T10:19:34Z</dc:date>
    </item>
    <item>
      <title>Re: Using order by in the select query</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/using-order-by-in-the-select-query/m-p/1960676#M394977</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;Try SELECT MAX(datum) ... command&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Anyways your first option seems fine. Its not the fastest solution, but surely will work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regrds&lt;/P&gt;&lt;P&gt;Tamá&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 28 Feb 2007 10:20:37 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/using-order-by-in-the-select-query/m-p/1960676#M394977</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-02-28T10:20:37Z</dc:date>
    </item>
    <item>
      <title>Re: Using order by in the select query</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/using-order-by-in-the-select-query/m-p/1960677#M394978</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;first one because order by in select make your performance decrease.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards&lt;/P&gt;&lt;P&gt;shiba dutta&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 28 Feb 2007 10:21:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/using-order-by-in-the-select-query/m-p/1960677#M394978</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-02-28T10:21:02Z</dc:date>
    </item>
    <item>
      <title>Re: Using order by in the select query</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/using-order-by-in-the-select-query/m-p/1960678#M394979</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;ORDER BY is obsolete.&lt;/P&gt;&lt;P&gt;The second approach is better when if you need maximum for each documnt.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;you can directly use the &lt;/P&gt;&lt;P&gt;select max * if you need only the maximum of all.&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Ravi&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 28 Feb 2007 10:22:04 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/using-order-by-in-the-select-query/m-p/1960678#M394979</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-02-28T10:22:04Z</dc:date>
    </item>
    <item>
      <title>Re: Using order by in the select query</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/using-order-by-in-the-select-query/m-p/1960679#M394980</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;The first one would be better.At the most we should not use order by in select statement bcoz it directly sorts the data according to that in database itself reverting performance issues.&lt;/P&gt;&lt;P&gt;Otherwise you can use select max* if records are less.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Reward points if helpful.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Ponraj.s.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 28 Feb 2007 10:25:56 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/using-order-by-in-the-select-query/m-p/1960679#M394980</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-02-28T10:25:56Z</dc:date>
    </item>
    <item>
      <title>Re: Using order by in the select query</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/using-order-by-in-the-select-query/m-p/1960680#M394981</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you all...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Shahu&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 28 Feb 2007 11:39:38 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/using-order-by-in-the-select-query/m-p/1960680#M394981</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-02-28T11:39:38Z</dc:date>
    </item>
  </channel>
</rss>

