 <p>Answer given by Arion is looking perfect to me. You can modify to this as per below to achieve your exact requirement</p> <pre><code>SELECT batch_id,run_count,start_date,end_date FROM ( SELECT ROW_NUMBER() OVER(PARTITION BY batch_id ORDER BY run_count DESC) AS RowNbr, batch_log.* FROM batch_log ) as batch WHERE batch.RowNbr=1 </code></pre>