Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 easy question who can answer faster!

Author  Topic 

midpenntech
Posting Yak Master

137 Posts

Posted - 2009-04-23 : 15:29:06
I have have 3 columns that I need to join into one column.

Custnuma,custnumc,custnumd would like to make it allcustnum


example

custnuma,custnumc,custnumd
12331,Null,Null
Null,43523,Null
Null,Null,95423

How i would want it then is
allcustnum
12331
43523
95423

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-04-23 : 15:33:53
Is your example actually the result of a GROUP BY query gone bad?

You can always use

SELECT COALESCE(CustNumA, CustNumC, CustNumD) AS AllCustNum
FROM ...

Or fix the original query is such exists.



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

midpenntech
Posting Yak Master

137 Posts

Posted - 2009-04-23 : 15:34:51
no it is not, i have mutiple views i needed to create that had case's from diff tables.
Go to Top of Page

Qualis
Posting Yak Master

145 Posts

Posted - 2009-04-23 : 15:34:56
If only one customer number will be populated amongst the 3, then this would work:

Select Coalesce(custnuma, custnumc, custnumd) As allcustnum


Edit:
Bah!! from the time I opened the post to when I submitted my answer, I was twarted!! Gotta be quicker on the draw I see...
Go to Top of Page
   

- Advertisement -