title: SQL Server : get latest date from 2 tables
body: <p>I have two tables P and G and want to write a query that will get the latest date from table G and will not pull in duplicate client IDs:</p>
  
  <p>Table P</p>
  
  <p><a href="https://i.stack.imgur.com/k99yX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/k99yX.png" alt="Table P"></a></p>
  
  <p>Table G</p>
  
  <p><a href="https://i.stack.imgur.com/iukgy.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/iukgy.png" alt="Table G"></a></p>
  
  <p>I want to get this result from the query:</p>
  
  <p><a href="https://i.stack.imgur.com/Qg4PV.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Qg4PV.png" alt="enter image description here"></a></p>
  
  <p>So far I have joined the tables, but unable get the result intended.</p>
  
  <p>Any help would be appreciated.</p>