title: SQL get row values for MAX() grouped by 2 columns
body: <p>Following on from <a href="https://stackoverflow.com/questions/46497384/sql-return-every-row-even-if-null-values/46505027#46505027">SQL Return every row even if Null values</a>  I need to SELECT the row data associated with the MAX(contractPrice) when grouped by two columns.  </p>
  
  <p>I've set up sqlfiddle.com/#!6/170043/2 to demonstrate that the problem is the code below returns duplicates (see 5th and 6th lines of sqlfiddle results) if the max price is repeated.</p>
  
  <pre><code>    SELECT
          t1.MeasurableID,
          t1.EntityID,
          t1.ContractPrice,
          ID,
          UTCMatched,
          NumberOfContracts,
          CurrencyCode
      FROM
          contracts AS t1
      INNER JOIN (
          SELECT
              MeasurableID,
              EntityID,
              MAX (contractprice) AS MAXprice
          FROM
              contracts
          WHERE
              MeasurableID IN (2017, 2018)
          AND CurrencyCode IN ('CAD', 'BTC')
          GROUP BY
              MeasurableID,
              EntityID
      ) t2 ON t1.MeasurableID = t2.MeasurableID
      AND t1.EntityID = t2.EntityID
      AND t1.ContractPrice = t2.MAXprice
      WHERE
          t1.MeasurableID IN (2017, 2018)
      AND t1.CurrencyCode IN ('CAD', 'BTC')
      ORDER BY
          MeasurableID,
          EntityID,
          UTCMatched
  </code></pre>