title: Retrieve max date for distinct IDs in a table
body: <p>I have the table ABC with the following data</p>
  
  <pre><code>Id  Name    Date      Execution id 
  --  ----  ---------  -------------
  1    AA   09SEP2019      11
  1    AA   08SEP2019      22
  1    AA   07SEP2019      33
  2    BB   09SEP2019      44
  2    BB   08SEP2019      55
  2    BB   07SEP2019      66
  </code></pre>
  
  <p>And I want to get for every distinct ID in the table its max date. So the result set must be as the following</p>
  
  <pre><code>Id Name     Date     Execution id 
  -- ----  ---------  -------------
  1   AA   09SEP2019      11
  2   BB   09SEP2019      44
  </code></pre>
  
  <p>The query that returns the result I need</p>
  
  <pre><code>WITH MaxDate as (
     SELECT Id,Name,Max(Date) from ABC group by Id,Name
  )
  SELECT view1.*, view2.exection_id
  from
         MaxDate view1,
         ABC     view2
  WHERE
         view1.date=view2.date and
         view1.name=view2.name;
  </code></pre>
  
  <p>I don't like to get the max date for the distinct ID by this way. May be there is another way ? Might be there is more easiest way?</p>