By piecing the screenshots together, it seems that you have a table with three columns: (year_added, track, artist) and you want the output looks like below:
track |2018 |2019 |2020 |2021 |
----------------------------------+-----------------------------------+----------------------------------------------+---------------------------------+-----------------------------------+
Alors on dance |Doug,Kieth,Roger |Alan,Chester,William |Nicholas |Maxwell |
Andalouse |Tyson |Daron,Domenic,Ramon |Barney,Chuck,Nicholas | |
Baila Morena | |Hayden,Sebastian | | |
Bailando |Brad |Chester,Elijah,George,Julian |Barry,Roger |Doug,Jack,Kurt,Matt,Rick,Rocco |
Beat it |Chris,Daniel |Denis |Tom |Bryon,John,Mike |
Beggin |Anthony |Chad,Mike,Noah |Josh,Rufus |Denis |
Bette Davis Eyes |Abdul,Eduardo |Carter,Jacob |Gil |Erick,Ron |
If so, the query below may work for you:
with cte as (
select track,
case when year_added = 2018 then string_agg(artist,',') end as "2018",
case when year_added = 2019 then string_agg(artist,',') end as "2019",
case when year_added = 2020 then string_agg(artist,',') end as "2020",
case when year_added = 2021 then string_agg(artist,',') end as "2021",
case when year_added = 2022 then string_agg(artist,',') end as "2022"
from tab_year_added
group by track, year_added)
select track,
max("2018") as "2018",
max("2019") as "2019",
max("2020") as "2020",
max("2021") as "2021",
max("2022") as "2022"
from cte
group by track
order by track;