title: How to select only one row of particular id? Not Solved with Distinct
body: <p>I have a SQL Server table <code>Restaurent</code> joined with <code>Product</code>:</p>
  
  <pre><code>SELECT 
      rm.RestaurantId, rm.RestaurantImage, rm.RestaurantName, 
      rm.RestaurantLocation,
      pm.ProductName, rm.IsActive,
      (6371 * acos(cos(radians(@userlat)) * cos(radians(RestaurantLatitude)) * cos(radians(RestaurantLongitude) - radians(@userlong)) + sin(radians(@userlat)) * sin(radians(RestaurantLatitude)))) AS distance 
  FROM 
      HomeMadeFood.dbo.RestaurentMaster AS rm 
  INNER JOIN
      ProductMaster AS pm ON pm.RestaurentId = rm.RestaurantId
  GROUP BY 
      rm.RestaurantId
  ORDER BY 
      distance ASC
  </code></pre>
  
  <p>This query returns output like this:</p>
  
  <pre><code>RestID     RestName      Distance    ProductName
  -------------------------------------------------
    1         A             16           Demo1
    2         B             20           Demo2
    1         A             16           Demo3
    3         C             50           Demo4      
  </code></pre>
  
  <p>My expected output should be like this</p>
  
  <pre><code>RestID     RestName      Distance    ProductName
  -------------------------------------------------
     1         A             16           Demo1
     2         B             20           Demo2
     3         C             50           Demo4  
  </code></pre>
  
  <p>If I use <code>group by</code> on <code>RestId</code> it throws an error on second column (Image)</p>