title: Split results of query in n subsets but respect togetherness of columns
body: <p>I'm terribly sorry if the question title is misleading; if an editor finds a better wording, please improve it!</p>
  
  <p>The scenario is the following: I need to do a Pivot on a huge set of data in of our GIS databases. The client wants to split this data into evenly parts as he sees fit and put this data onto different Excel sheets.</p>
  
  <p>To do this Pivot I first get all the columns I need into a variable called <code>@column_list</code> and split them evenly using <code>ntile()</code>:</p>
  
  <pre><code>SELECT @column_list = @column_list + srcTable.colName
   FROM (
      SELECT '[' + l.LONGNAME + ' (' + CONVERT(varchar(10), [SMPDATE], 104) + ')],' as colName
        ,NTILE(@Divider) over(order by l.LONGNAME, m.SMPDATE) as tile_nr
     FROM [GEODIN_MES_WASTAB01] m
    INNER JOIN GEODIN_LOC_ASBFILTR f
       ON m.INVID = f.INVID 
    INNER JOIN GEODIN_LOC_SSGKRZT1 l
       ON f.PRJ_ID = l.PRJ_ID AND
          f.LOCID  = l.LOCID 
    WHERE m.SMPDATE &gt;= @Startdate AND m.SMPDATE &lt;= @Enddate
  ) srcTable
  WHERE srcTable.tile_nr = @Subset
  </code></pre>
  
  <p>Now this gives me a list of columns, which look similar to this:</p>
  
  <pre><code>[A1 (01.01.2011)] [A1 (10.01.2011)] ... [B16 (10.7.2012)] ... [X67 (11.12.2014)]
  </code></pre>
  
  <p>The problem here is, that I cannot allow the data to be split in between a set of columns with the same longname! So if there are 10 columns with <code>[A1 (date)]</code>, it is not possible to put 3 items on tile 1 where the remaining 7 are put on tile 2:</p>
  
  <pre><code>TILE1            |            TILE1        |        TILE2
  -------------------------------------------------------------
  [A1 (01.01.2011)]|    [A1 (10.01.2011)]      [A3 (10.7.2012)] 
  </code></pre>
  
  <p>Are there alternatives here, that work roughly like NTILE, but respect the criteria, that all LONGNAMES need to be on the same tile?</p>