title: select single row of multiple records in One to Many relation tables
body: <p>In MSSQL, I have two tables with one to many relation.</p>
  
  <p>Tables:</p>
  
  <pre><code>tb_Products:
  ID
  ProductName
  
  tb_Images:
  ProductID
  MidPath
  </code></pre>
  
  <p>In Stored Procedure, shows products with their images (also shows null records),
  And if there is multiple productIDs in tb_Images, it shows a single record.</p>
  
  <p>I can make this work by this Query:</p>
  
  <pre><code>declare @rowIndexToFetch int
  set @rowIndexToFetch=0
  
  select p.ID,p.ProductName,p.CategoryID,c.ParentId,  
      pi.MidPath
      from tb_Products p
      join tb_Categories c
      on p.CategoryID=c.ID
      left outer join tb_Images pi
      on pi.ProductID=p.ID
  
      where c.ID=3 or c.ParentId=3
  
      order by pi.ID desc
      offset @rowIndexToFetch rows
      fetch next 1 rows only
  </code></pre>
  
  <p>But, if I use offset and fetch, I no longer can retrieve NULL records from tb_Images. Left outer join does not work anymore.</p>
  
  <p>Example record returns without offset-fetch:</p>
  
  <pre><code>ID    ProductName   CategoryID   ParentId  MidPath
  154   Chef Ceket     33            3       /cdn/www.sample.com/x
  154   Chef Ceket     33            3       /cdn/www.sample.com/y
  154   Chef Ceket     33            3       /cdn/www.sample.com/z
  1     Eldiven        3             3       NULL
  </code></pre>
  
  <p>with offset-fetch:</p>
  
  <pre><code>ID    ProductName   CategoryID   ParentId  MidPath
  154   Chef Ceket     33            3       /cdn/www.sample.com/x
  </code></pre>
  
  <p>expected to return:</p>
  
  <pre><code>   ID    ProductName   CategoryID   ParentId  MidPath
     154   Chef Ceket     33            3       /cdn/www.sample.com/x
     1     Eldiven        3             3       NULL
  </code></pre>
  
  <p>The problem is, I cannot retrieve null records when I use offset-fetch statement. How can I fix this?</p>