SSRS, , , "" ( ):
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) '#', type, count (type) FROM title GROUP BY type ORDER BY type
SELECT @cntMax = max (#) @varTable
INSERT @table1 (type, title, ord) SELECT, N '', 1 FROM title
INSERT @table2 (type, title, ord) SELECT, , 1 FROM title
SET @CurrentRow = 0
SET @SelectedType = N ''
SET @NumberOfLines = @RowsPerPage
SELECT @RowsToProcess = COUNT (*) @varTable
WHILE @CurrentRow < @RowsToProcess
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 source
share