CASE WHEN Col1 = 1 THEN
(CASE WHEN Col2=2 THEN 'a' + ', ' END) +
(CASE WHEN Col3=2 THEN 'b' + ', ' END) +
(CASE WHEN Col4=2 THEN 'c' END)
END as Names
Names can be a,b,c or a,b, or b,
How do I remove the character "," at the end? I cannot use replace or stuff etc functions as "Names" is an alias
original Query:
CASE WHEN ht.bTax=0 then
ISNULL(CASE WHEN (r1.iOccType=2) THEN p1.SFIRSTNAME + ' ' + p1.ULASTNAME END,'') + ISNULL(CASE WHEN (r2.iOcctType=2) THEN p2.SFIRSTNAME + ' ' + p2.ULASTNAME + ', ' END, '') + ISNULL(CASE WHEN (r3.iOccType=2) THEN p3.SFIRSTNAME + ' ' + p3.ULASTNAME + ', ' END, '') + ISNULL(CASE WHEN (r4.iOccType=2) THEN p4.SFIRSTNAME + ' ' + p4.ULASTNAME + ', ' END, '') + ISNULL(CASE WHEN (r5.iOccType=2) THEN p5.SFIRSTNAME + ' ' + p5.ULASTNAME + ', ' END, '') End AS Names