Author |
Topic |
cutiebo2t
Constraint Violating Yak Guru
256 Posts |
Posted - 2008-07-22 : 06:02:59
|
I have 3 columns. Level1a Level1b Levelc. I want to merge them into 1 column. Is that possible? Thanks |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2008-07-22 : 06:11:36
|
yes.How do you want to merge it ?concatenate ? select Level1a + Level1b + Levelc from yourtable KH[spoiler]Time is always against us[/spoiler] |
|
|
cutiebo2t
Constraint Violating Yak Guru
256 Posts |
Posted - 2008-07-22 : 06:23:51
|
I want to combine them into 1 column |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-07-22 : 06:26:43
|
select coalesce(Level1a,'')+coalesce( Level1b,'') + coalesce(Levelc,'') from yourtable |
|
|
dexter.knudson
Constraint Violating Yak Guru
260 Posts |
Posted - 2008-07-22 : 06:28:33
|
update <tableName>set <newColumnName> = Level1a + ';' + Level1b + ';' + Levelc You can leave out the + ';' if you don't want anything in between, or you could make it a blank space if you wish. This assumses that your colmns are strings. |
|
|
cutiebo2t
Constraint Violating Yak Guru
256 Posts |
Posted - 2008-07-22 : 06:30:18
|
it doesn't combined into 1 column instead it merged in the same cell. |
|
|
cutiebo2t
Constraint Violating Yak Guru
256 Posts |
Posted - 2008-07-22 : 06:38:35
|
any help? |
|
|
elancaster
A very urgent SQL Yakette
1208 Posts |
Posted - 2008-07-22 : 06:46:03
|
how about some sample data to show us what you mean? guessing could take foreverEm |
|
|
cutiebo2t
Constraint Violating Yak Guru
256 Posts |
Posted - 2008-07-22 : 06:47:16
|
Level1 abLevel2cdCombined with new columnLevelabcd |
|
|
elancaster
A very urgent SQL Yakette
1208 Posts |
Posted - 2008-07-22 : 06:52:31
|
that just looks like a union?i.e.select level1from UrTableunion allselect level2from UrTablewhat about other columns? limiting the rows etc...?Em |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
|
cutiebo2t
Constraint Violating Yak Guru
256 Posts |
Posted - 2008-07-22 : 06:56:29
|
SELECT level1FROM dbo.Comments_Scrub_FormUNION ALLSELECT level2FROM dbo.Comments_Scrub_Form, SELECT level3 FROM dbo.Comments_Scrub_FormUNION ALLSELECT level4FROM dbo.Comments_Scrub_FormThis is not working |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-07-22 : 07:02:42
|
quote: Originally posted by cutiebo2t SELECT level1FROM dbo.Comments_Scrub_FormUNION ALLSELECT level2FROM dbo.Comments_Scrub_Form, SELECT level3 FROM dbo.Comments_Scrub_FormUNION ALLSELECT level4FROM dbo.Comments_Scrub_FormThis is not working
It wont as you have unnecessary commaMadhivananFailing to plan is Planning to fail |
|
|
cutiebo2t
Constraint Violating Yak Guru
256 Posts |
Posted - 2008-07-22 : 07:03:27
|
I need to columns but it doesn't work:SELECT level1FROM dbo.Comments_Scrub_FormUNION ALLSELECT level2FROM dbo.Comments_Scrub_Form SELECT level3 FROM dbo.Comments_Scrub_FormUNION ALLSELECT level4FROM dbo.Comments_Scrub_Form |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-07-22 : 07:05:06
|
quote: Originally posted by cutiebo2t I need to columns but it doesn't work:SELECT level1FROM dbo.Comments_Scrub_FormUNION ALLSELECT level2FROM dbo.Comments_Scrub_Form SELECT level3 FROM dbo.Comments_Scrub_FormUNION ALLSELECT level4FROM dbo.Comments_Scrub_Form
What do you mean by "it doesnt work"?MadhivananFailing to plan is Planning to fail |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-07-22 : 07:06:05
|
What is the problem now?Do you want us to continue guessing?!!?Follow the links I posted earlier and give us a chance to help you.quote: This is the link I have posted to you several times before. PLEASE READ and UNDERSTAND the conceptand you will get help faster.http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspxIt isn't that hard to follow the guidelines.And here is another link for you, so that you will understand what WE face when YOU ask a question in your present manner.http://weblogs.sqlteam.com/jeffs/archive/2008/05/13/question-needed-not-answer.aspx
IF YOU DON'T FOLLOW THE GUIDELINES POSTED ABOVE, WE CAN'T HELP YOU BECUASE WE CAN'T READ YOU MIND. E 12°55'05.25"N 56°04'39.16" |
|
|
cutiebo2t
Constraint Violating Yak Guru
256 Posts |
Posted - 2008-07-22 : 07:06:17
|
I want level1 and level2 into 1 column and level3 and level4 into another column. Thanks |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-07-22 : 07:08:12
|
You still can't follow directions, can't you? E 12°55'05.25"N 56°04'39.16" |
|
|
cutiebo2t
Constraint Violating Yak Guru
256 Posts |
Posted - 2008-07-22 : 07:09:59
|
Level1abLevel2cdCombined with new columnLevelabcdAnother that neends to combinedLevel3efLevel4ghInto new columnefghIt's not working here:SELECT level1FROM dbo.Comments_Scrub_FormUNION ALLSELECT level2FROM dbo.Comments_Scrub_Form AS test SELECT level3 FROM dbo.Comments_Scrub_FormUNION ALLSELECT level4FROM dbo.Comments_Scrub_Form |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-07-22 : 07:11:48
|
Please tell me why you are so reluctant to make things easier for us?Follow the guidelines in this topic http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspxSo that we know EXACTLY how the data looks like and how you want it presented.CREATE TABLE #Temp1 ( RowID INT IDENTITY(1, 1), Col INT )CREATE TABLE #Temp2 ( RowID INT IDENTITY(1, 1), Col INT )INSERT #Temp1SELECT Level1 FROM dbo.Comments_Scrub_Form UNIONSELECT Level2 FROM dbo.Comments_Scrub_FormORDER BY 1INSERT #Temp2SELECT Level3 FROM dbo.Comments_Scrub_Form UNIONSELECT Level4 FROM dbo.Comments_Scrub_Form-- OutputSELECT t1.Col, t2.ColFROM #Temp1 AS t1FULL JOIN #Temp2 AS t2 ON t2.RowID = t1.RowID E 12°55'05.25"N 56°04'39.16" |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-07-22 : 07:13:09
|
Where do you want to show data?If you use front end application, show thereMadhivananFailing to plan is Planning to fail |
|
|
Next Page
|