With data such as this:
Column A Column B
1 98
1 12
1 21
1 31
2 37
2
First, you need to extract unique value from Column A to Column C. You can do it by using Advance Filter method or you can use below formula.
=IFERROR(INDEX($A$2:$A$18,MATCH(0,INDEX(COUNTIF($C$1:C1,$A$2:$A$18),0,0),0)),"")
After extracting unique values you have to use TEXTJOIN() formula to aggregate values from Column B to Column D. You have TEXTJOIN() formula in your excel version then you can use it like below
=TEXTJOIN(", ",TRUE,IF($A$2:$A$18=C2,$B$2:$B$18,""))
Otherwise you have to user VBA custom function to write TextJoin() formula. For TEXTJOIN() custom function you can have look to this post. Post Link