Вы можете использовать табличные переменные в запросе набора данных SSRS, как в моем коде, где я добавляю необходимые «пустые» записи для хранения нижнего колонтитула группы в фиксированном положении (пример использования базы данных pubs):
DECLARE @NumberOfLines INT
DECLARE @RowsToProcess INT
DECLARE @CurrentRow INT
DECLARE @CurRow INT
DECLARE @cntMax INT
DECLARE @NumberOfRecords INT
DECLARE @SelectedType char(12)
DECLARE @varTable TABLE (# int, type char(12), ord int)
DECLARE @table1 TABLE (type char(12), title varchar(80), ord int )<br>
DECLARE @table2 TABLE (type char(12), title varchar(80), ord int ) </p>
<p>INSERT INTO @varTable
SELECT count(type) as '#', type, count(type) FROM titles GROUP BY type ORDER BY type
SELECT @cntMax = max(#) from @varTable</p>
<p>INSERT into @table1 (type, title, ord) SELECT type, N'', 1 FROM titles
INSERT into @table2 (type, title, ord) SELECT type, title, 1 FROM titles </p>
<p>SET @CurrentRow = 0
SET @SelectedType = N''
SET @NumberOfLines = @RowsPerPage</p>
<p>SELECT @RowsToProcess = COUNT(*) from @varTable </p>
<p>WHILE @CurrentRow < @RowsToProcess
BEGIN<br>
SET @CurrentRow = @CurrentRow + 1</p>
<code>SELECT TOP 1 @NumberOfRecords = ord, @SelectedType = type
FROM @varTable WHERE type > @SelectedType
SET @CurRow = 0
WHILE @CurRow < (@NumberOfLines - @NumberOfRecords % @NumberOfLines) % @NumberOfLines
BEGIN
SET @CurRow = @CurRow + 1
INSERT into @table2 (type, title, ord)
SELECT type, '' , 2
FROM @varTable WHERE type = @SelectedType
END
END
SELECT type, title FROM @table2 ORDER BY type ASC, ord ASC, title ASC
</code>