Considera questo esempio:
--qua creo una tabella come potrebbe essere la tua
drop table #t
select *
into #t
from (
select'2017-25EUR-03'CardCode ,'hlavelle'UserName union all
select'2017-25EUR-04'CardCode ,'hlavelle'UserName union all
select'2017-25EUR-05'CardCode ,'hlavelle'UserName union all
select'2017-25EUR-06'CardCode ,'hlavelle'UserName union all
select'2017-25EUR-07'CardCode ,'hlavelle'UserName union all
select'2017-25EUR-08'CardCode ,'hlavelle'UserName union all
select'2017-25EUR-09'CardCode ,'hlavelle'UserName union all
select'2017-25EUR-10'CardCode ,'hlavelle'UserName union all
select'2017-25EUR-11'CardCode ,'hlavelle'UserName union all
select'2017-25EUR-12'CardCode ,'hlavelle'UserName union all
select'2017-25EUR-13'CardCode ,'hlavelle'UserName union all
select'2017-25EUR-14'CardCode ,'hlavelle'UserName union all
select'2017-25EUR-16'CardCode ,'hlavelle'UserName union all
select'CHRISTMAS7'CardCode ,'hlavelle'UserName union all
select'GREETING1'CardCode ,'hlavelle'UserName union all
select'GREETING2'CardCode ,'hlavelle'UserName union all
select'TEST-USAGE'CardCode ,'hlavelle'UserName union all
select'2017-25EUR-01'CardCode ,'hlenzen'UserName union all
select'2017-25EUR-02'CardCode ,'hlenzen'UserName union all
select'2017-25EUR-03'CardCode ,'hlenzen'UserName union all
select'2017-25EUR-04'CardCode ,'hlenzen'UserName union all
select'2017-25EUR-05'CardCode ,'hlenzen'UserName union all
select'2017-25EUR-06'CardCode ,'hlenzen'UserName union all
select'2017-25EUR-07'CardCode ,'hlenzen'UserName union all
select'2017-25EUR-08'CardCode ,'hlenzen'UserName union all
select'2017-25EUR-09'CardCode ,'hlenzen'UserName union all
select'2017-25EUR-10'CardCode ,'hlenzen'UserName union all
select'2017-25EUR-11'CardCode ,'hlenzen'UserName union all
select'2017-25EUR-12'CardCode ,'hlenzen'UserName union all
select'2017-25EUR-13'CardCode ,'hlenzen'UserName)t
SELECT *
FROM
(
--qua dovrai sostituire la tua tabella
--in aggiunta di un progressivo "row_number()over(partition by UserName order by (select 0))r" in cui, per ogni utente, genero un valore progressivo dato che presumo che il codice sia basato sulla data, x cui non statico.
select row_number()over(partition by UserName order by (select 0))r,*
from #t
) AS SourceTable
PIVOT
(
max(cardcode)
--qua definisco la profondità dei valori che posso estrarre, questo è statico!
FOR r IN ([1], [2], [3], [4], [5], [6], [7], [8], [9], [10], [11], [12], [13], [14], [15], [16], [17], [18], [19])
) AS PivotTable;
questo il riferimento: