1

I have a list of codes for same IDs with ranking, I want to have these codes in a coma separated way by there rank in ASC order like (71,49,490,41,61,42,62,614,615,621), when I am using string_agg(code,"," ORDER BY rank_) it is showing below error:

Error Msg

List:

List

saeed foroughi
  • 1,662
  • 1
  • 13
  • 25
  • You have a low rate. Important on SO, you have to mark accepted answers by using the tick on the left of the posted answer, below the voting. This will increase your rate. See how this works by visinting this link: http://meta.stackoverflow.com/questions/5234/how-does-accepting-an-answer-work#5235 – Pentium10 Feb 04 '20 at 07:17

1 Answers1

3

You need to CAST your int into string.

string_agg(CAST(code as STRING),"," ORDER BY rank_)
Pentium10
  • 204,586
  • 122
  • 423
  • 502