title: How to get the max date per month
body: <p>I have a table like</p>
  
  <pre><code>kunnr        date            posnr
  30001        28/5/2017       1
  30001        25/5/2017       2
  30001        15/5/2017       3
  30001        25/4/2017       4
  30001        20/4/2017       5
  30002        15/5/2017       6
  30002        25/4/2017       7
  </code></pre>
  
  <p>I want for every new kunnr to get the record with the max date per month, namely the max for May and max for April etc.</p>
  
  <p>OK, I will sort the table loop at it and for every new kunnr .... how I will get the record for max date for each month?</p>
  
  <p>Thanks in advance
  Elias</p>
  
  <p>PS: sth went wrong and I realise that I do not get what I want. I have the following lines in a table</p>
  
  <pre><code>0000527746  1000    10.06.2017  20170718100757.5010080
  0000527746  1000    10.06.2017  20170718100757.5039300
  0000527746  1000    11.06.2017  20170718100839.9209480
  0000527746  1000    11.06.2017  20170718100906.3337170
  0000527746  1000    24.07.2017  20170718095843.3555610
  0000527746  1000    24.07.2017  20170718100209.2203570
  0000527746  1000    24.07.2017  20170718100757.4970390
  </code></pre>
  
  <p>and I want to select the last date of each month namely I want the select to bring me the following lines</p>
  
  <pre><code>0000527746  1000    11.06.2017  20170718100906.3337170
  0000527746  1000    24.07.2017  20170718100757.4970390
  </code></pre>
  
  <p>I use the following sql</p>
  
  <pre><code>select bukrs kunnr dat max( time ) as time
      from zcollectoraction into corresponding fields of table it_collectoraction
      where bukrs = p_bukrs and
            kunnr in so_kunnr and
            dat   in so_date
      group by bukrs kunnr dat.
  </code></pre>
  
  <p>but it displays the following lines</p>
  
  <pre><code>0000527746  1000    11.06.2017  20170718100906.3337170
  0000527746  1000    11.06.2017  20170718100906.3337170
  0000527746  1000    24.07.2017  20170718100757.4970390
  </code></pre>
  
  <p>What to do in order to have 1 line per month?</p>
  
  <p>Thanks
  Elias</p>