There is a table with values like this:
Sets | Reps
-----+------
2 | 10
3 | 15
3 | 12
4 | 8
I need to combine those two values into one in my SELECT statement, so I could get
SELECT ... AS Reps FROM Table
Reps
------------
10,10
15,15,15
12,12,12
8,8,8,8
Any ideas how to do this?
Testing script:
DECLARE @Test TABLE ([Sets] INT, [Reps] INT);
INSERT INTO @Test VALUES (2, 10);
INSERT INTO @Test VALUES (3, 15);
INSERT INTO @Test VALUES (3, 12);
INSERT INTO @Test VALUES (4, 8);
SELECT [Sets], [Reps] FROM @Test;
// Here is an answer by tpdi:
SELECT CAST([Reps] AS VARCHAR) +
REPLICATE(',' + CAST([Reps] AS VARCHAR), [Sets] - 1)
AS [Reps] FROM @Test;