<?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: Select Query in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-query/m-p/4211357#M1006341</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;Use the 'MAX' function.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select MAX ( &amp;lt;fieldname&amp;gt; )&lt;/P&gt;&lt;P&gt;         from &amp;lt;tablename&amp;gt;&lt;/P&gt;&lt;P&gt;         into  &amp;lt;variablename&amp;gt;&lt;/P&gt;&lt;P&gt;         based on the conditions.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The above function selects the maximum value of the given field from the table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Reward if helpful,&lt;/P&gt;&lt;P&gt;Sharin.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 22 Jul 2008 05:43:29 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2008-07-22T05:43:29Z</dc:date>
    <item>
      <title>Select Query</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-query/m-p/4211354#M1006338</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;How will write a select query where a date field should be maximum out of all values present for that field?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 22 Jul 2008 05:37:28 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-query/m-p/4211354#M1006338</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-07-22T05:37:28Z</dc:date>
    </item>
    <item>
      <title>Re: Select Query</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-query/m-p/4211355#M1006339</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi&lt;/P&gt;&lt;P&gt;  use aggregate function MAX on that praticular date field&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sample snippet&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT&lt;/P&gt;&lt;P&gt;  MAX( erdat )&lt;/P&gt;&lt;P&gt;  INTO ( w_d )&lt;/P&gt;&lt;P&gt;  FROM mara.&lt;/P&gt;&lt;P&gt;ENDSELECT. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;observe the MAX aggregate funtion&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards&lt;/P&gt;&lt;P&gt;pavan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 22 Jul 2008 05:41:03 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-query/m-p/4211355#M1006339</guid>
      <dc:creator>bpawanchand</dc:creator>
      <dc:date>2008-07-22T05:41:03Z</dc:date>
    </item>
    <item>
      <title>Re: Select Query</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-query/m-p/4211356#M1006340</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi yogesh,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Use the aggregate &lt;STRONG&gt;MAX&lt;/STRONG&gt; addition with date field.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;MAX( [DISTINCT] col )&lt;/STRONG&gt; - Determines the maximum value of the value in the column col in the resulting set or in the current group. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;U&gt;Example&lt;/U&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;DATA: name     TYPE scustom-name, 
      postcode TYPE scustom-postcode, 
      city     TYPE scustom-city, 
      max      TYPE sbook-loccuram. 

SELECT scustom~name scustom~postcode scustom~city 
         MAX( sbook~loccuram ) 
       INTO (name, postcode, city, max) 
       FROM scustom INNER JOIN sbook 
         ON scustom~id = sbook~customid 
       WHERE sbook~fldate BETWEEN '20010101' AND '20011231' AND 
             sbook~carrid   = 'LH '                         AND 
             sbook~connid   = '0400' 
       GROUP BY scustom~name scustom~postcode scustom~city 
       ORDER BY scustom~name. 
  WRITE: / name, postcode, city, max. 
ENDSELECT.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best of luck,&lt;/P&gt;&lt;P&gt;Bhumika&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 22 Jul 2008 05:41:12 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-query/m-p/4211356#M1006340</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-07-22T05:41:12Z</dc:date>
    </item>
    <item>
      <title>Re: Select Query</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-query/m-p/4211357#M1006341</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;Use the 'MAX' function.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select MAX ( &amp;lt;fieldname&amp;gt; )&lt;/P&gt;&lt;P&gt;         from &amp;lt;tablename&amp;gt;&lt;/P&gt;&lt;P&gt;         into  &amp;lt;variablename&amp;gt;&lt;/P&gt;&lt;P&gt;         based on the conditions.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The above function selects the maximum value of the given field from the table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Reward if helpful,&lt;/P&gt;&lt;P&gt;Sharin.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 22 Jul 2008 05:43:29 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-query/m-p/4211357#M1006341</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-07-22T05:43:29Z</dc:date>
    </item>
  </channel>
</rss>

