Try something like this:WITH Repeater(number) AS( SELECT 1 UNION ALL SELECT 2 UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL SELECT 3 UNION ALL SELECT 3), CTE(tag, name) AS( SELECT 'Number1', N.Name FROM Names AS N INNER JOIN Repeater AS R ON R.number = N.Number1 UNION ALL SELECT 'Number2', N.Name FROM Names AS N INNER JOIN Repeater AS R ON R.number = N.Number2 UNION ALL SELECT 'Number3', N.Name FROM Names AS N INNER JOIN Repeater AS R ON R.number = N.Number3)SELECT ROW_NUMBER() OVER(ORDER BY T.name) AS rownum, T.tag, T.name FROM CTE AS T;
For us, there is only the trying. The rest is not our business. ~T.S. EliotMuhammad Al Pasha