title: Select Multiple value from a table but group by one value
body: <p>I am trying to select multiple values from two tables but i want to group by single value. I have tried using max(value) in select but max is returning the greatest one and not the exact one.</p>
  
  <p>Here are my tables 
  <a href="https://i.stack.imgur.com/cDXi9.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cDXi9.png" alt="enter image description here"></a></p>
  
  <p>The result i need is something like this </p>
  
  <pre><code>Result : HeadQuarterId - A, PropertyName - Name1, Amount - 102
           HeadQuarterId - B, PropertyName - Name5, Amount - 30
  </code></pre>
  
  <p>Here is my query</p>
  
  <pre><code>SELECT  Headquarterid,Max(PropertyName),sum(Amount)  
  FROM Table1 A LEFT OUTER JOIN Table2 B
  ON A.Propetyid = B.PropertyId  
  GROUP BY Headquarterid
  </code></pre>
  
  <p>Here i have used Left Outer Join so that i will get all the data from left table even it is not available in right table.</p>
  
  <p>Also i cannot use A.HeadquarterID = A.PropertyId in where condition  since i have other dependency in that table. Please suggest someother way to achieve this result.</p>