title: Replacing part of a string SQL based on condition
body: <p>I have a use case in amazon redshift which I have a list of numbers in a column:
  E.g:
  <code>1,2,3,4,5,6</code>
  For this use case, the numbers have to be in the same column.
  Lets say that I want to pass a parameter and remove that number from the list. The thing I try to do is:</p>
  
  <pre><code>IF FIRST ENTRY THEN
  update table set number = replace(number,'{0},','') where 
  username = '{1}';
  ELSE
  update table set number = replace(number,',{0}','') where 
  username = '{1}';
  END IF;
  </code></pre>
  
  <p>So basically I try to remove the number from the list. The problem is removing the first number since there is no comma before that number. How can I remove the number+comma if it is the first entry and remove comma+number for all the other entries?</p>
  
  <p>Thanks for any help in advance </p>