title: get maximum date in separated columns (month and year)
body: <p>I have this table :</p>
  
  <pre><code>Month   Year    Provider    Number
  1       2015    1           345
  2       2015    1           345
  3       2015    1           345
  12      2015    2           444
  1       2016    2           444
  </code></pre>
  
  <p>Let's say I want to get all different numbers by provider but only the max month and max year, something like this:</p>
  
  <pre><code>Month   Year    Provider    Number
  3       2015    1           345
  1       2016    2           444
  </code></pre>
  
  <p>I have this ugly query that I would like to improve :</p>
  
  <pre><code>SELECT (SELECT max([Month]) 
          FROM dbo.Info b
          WHERE b.Provider = a.Provider
            AND b.Number = a.Number
            AND [Year] = (SELECT max([Year]) 
                            FROM dbo.Info c
                           WHERE c.Provider = a.Provider
                             AND c.Number = a.Number)) AS [Month],
          (SELECT max([Year]) 
             FROM dbo.Info d
            WHERE d.Provider = a.Provider
              AND d.Number = a.Number)) AS [Year],
          a.Provider,
          a.Number
   FROM dbo.Info a
  </code></pre>