Hi coders,
I have a table in which i need to concatenate columns but i dont want NULL value in it. Example:
ProductTable
Customer_Number Product1 Product2 Product3 Product3
1 NULL X Y NULL
2 NULL A B NULL
3 V NULL H NULL
Now want i want is the data in concatenated manner for product only like this:
Customer_Number Product
1 X,Y
2 A,B
3 V, H
I already try Coalease, Stuff, ISNULL, NULLIF but in all i m getting like below
Customer_Number Product
1 NULL,X,Y,NULL
2 NULL,A,B,NULL
3 V, NULL,H,NULL
This is the code i used:
Select Customer_number, ISNULL(IFNULLIF(Product1,' ')+',','')+
ISNULL(IFNULLIF(Product2,' ')+',','')+
ISNULL(IFNULLIF(Product3,' ')+',','')+
ISNULL(IFNULLIF(Product4,' ')+',','')
As Product from productTable
Any help will be appriciated !!!

Subodh Natoo45 reputationPosted Jul 18, 2017, 1:33 AM EDT
Bineesh ViswanathRank #1,680 · 907 reputationPosted Jul 13, 2017, 8:56 AM EDT
Manimekalai GanesanRank #1,304 · 1.3K reputationPosted Jul 14, 2017, 2:19 AM EDT