title: Grouping data with specified max data
body: <p>Good day, I'm sorry with my title. Ok, For an example i have this data</p>
  
  <pre><code>OutletAsal  OutletTujuan    remark  ExternalDocNo   ItemCode    Qty
  K-AEON        K-AR4         DUS 20  CLOSING       WFS170402776  2
  K-AEON        K-AR4         DUS 20  CLOSING       WFS170402758  1
  K-AEON        K-AR4         DUS 20  CLOSING       WFS170402790  1
  K-AEON        K-AR4         DUS 20  CLOSING       WFS170502796  2
  K-AEON        K-AR4         DUS 20  CLOSING       WHS170400011  1
  K-AEON        K-AR4         DUS 20  CLOSING       WHS170400015  1
  K-AEON        K-AR4         DUS 21  CLOSING       WHS170400015  1
  </code></pre>
  
  <p>So, i want to achieve this (Grouping OutletAsal,OutletTujuan,Remark,ExtrnalDocNo Maximum 5 records, if there is 6 records then it will make 2 headers)</p>
  
  <pre><code>#Header
  OutletAsal  OutletTujuan    remark  ExternalDocNo HeaderID
  K-AEON        K-AR4         DUS 20  CLOSING         1
  K-AEON        K-AR4         DUS 20  CLOSING         2
  K-AEON        K-AR4         DUS 21  CLOSING         3
  
  #detail
       ItemCode     Qty  HeaderID
      WFS170402776   2     1
      WFS170402758   1     1
      WFS170402790   1     1
      WFS170502796   2     1
      WHS170400011   1     1
      WHS170400015   1     2
      WHS170400015   1     3
  </code></pre>
  
  <p>For now i have this query for <code>header</code> part</p>
  
  <pre><code>SELECT LTRIM(RTRIM(OutletAsal)) OutletAsal,LTRIM(RTRIM(OutletTujuan)) OutletTujuan,Remark,
  ROW_NUMBER() OVER(ORDER BY OutletAsal,OutletTujuan,Remark ASC) AS Urut
  into #tempgroup
  FROM ImportCsvDO
  GROUP BY OutletAsal ,OutletTujuan , Remark ,ExternalDocNo
  </code></pre>
  
  <p>with my query above i get this and this is not like i expected (Please check above)</p>
  
  <pre><code>OutletAsal  OutletTujuan    Remark  Urut
  K-AEON       K-AR4           DUS 20 1
  K-AEON       K-AR4           DUS 21 2
  </code></pre>
  
  <p>Thanks in advance and sorry for my bad english.</p>