title: sql query select only one row from multiple rows
body: <p>I have this query: </p>
  
  <pre><code>SELECT p.[PostingID]
        ,[EmployerID]
        ,[JobTitle]                  
        ,pin.[IndustryID]         
  FROM [Posting] p
  INNER JOIN [City] c
    ON p.CityID = c.CityID
  LEFT OUTER JOIN PostingIndustry pin
    ON p.PostingID = pin.PostingID
  WHERE (c.CityID = @CityId OR @CityId IS NULL) 
    AND (p.StateProvinceID = @StateProvinceId OR @StateProvinceId IS NULL) 
    AND (pin.IndustryID = @IndustryId OR @IndustryId IS NULL) 
    AND 
    (
       (p.[Description] LIKE '%' + @Keyword + '%' OR @Keyword IS NULL) 
       OR (p.[JobTitle] LIKE '%' + @Keyword + '%'  OR @Keyword IS NULL)
    ) 
    AND p.StreetAddress IS NOT NULL 
    AND p.ShowOnMap = 1
  </code></pre>
  
  <p>Which returns results for all the pin.[IndustryID] if IndustryId is not selected or if all the industries are selected. If only one industry is selected I am getting one result which is good, but when one posting is included in multiple industries then I am getting multiple results as on  the image shown below:</p>
  
  <p><img src="https://i.stack.imgur.com/J4cN8.png" alt="enter image description here"></p>
  
  <p>So for example when thats happening I want to get only one result for that posting id otherwise I am getting multiple results for one google map marker per the image below:
  <img src="https://i.stack.imgur.com/S4Okx.png" alt="enter image description here"></p>
  
  <p>Is there a way how I can optimize the query above to do what I need?
  Thanks in advance, Laziale</p>