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 !!!
3 Replies
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Subodh NatooPosted Jul 18, 2017, 5:33 AM
Manimekalai GanesanPosted Jul 14, 2017, 6:19 AM
Bineesh ViswanathPosted Jul 13, 2017, 12:56 PM