你可以在我的代码在那里我加入了保组页脚需要“空”记录在固定现在的位置是使用在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)
DECLARE @table2 TABLE (type char(12), title varchar(80), ord int)
INSERT INTO @varTable
SELECT count(type) as '#', type, count(type) FROM titles GROUP BY type ORDER BY type
SELECT @cntMax = max(#) from @varTable
INSERT into @table1 (type, title, ord) SELECT type, N'', 1 FROM titles
INSERT into @table2 (type, title, ord) SELECT type, title, 1 FROM titles
SET @CurrentRow = 0
SET @SelectedType = N''
SET @NumberOfLines = @RowsPerPage
SELECT @RowsToProcess = COUNT(*) from @varTable
WHILE @CurrentRow < @RowsToProcess
BEGIN
SET @CurrentRow = @CurrentRow + 1
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
谢谢。我很害怕这个答案:) – edosoft 2010-08-05 07:56:23