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.
| Author |
Topic |
|
sassora
Starting Member
2 Posts |
Posted - 2008-01-29 : 18:05:48
|
| Does anyone know how to combine to columns into one using sql?For exampleSay I want to create a column3:column1 _____ column2------------------------------primary _____ secondaryprimary _____ [Non Applicable]tertiary _____ quad..somethingand IF column1 = primary AND column2 = secondary THEN column3 = newvalueThis is easy is access (and excel) but it doesn't seem to work in the same way in sql. |
|
|
jdaman
Constraint Violating Yak Guru
354 Posts |
Posted - 2008-01-29 : 18:18:33
|
| [code]SELECT column1, column2, CASE WHEN column1 = 'primary' AND column2 = 'secondary' THEN 'newvalue' ELSE 'someothervalue' END as column3[/code] |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-01-29 : 18:19:20
|
SELECT *, CASE WHEN Col1 = 'Primary' AND Col2 = 'Secondary' THEN 'newvalue' else null end as col3FROM Table1 E 12°55'05.25"N 56°04'39.16" |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-01-29 : 18:19:58
|
 E 12°55'05.25"N 56°04'39.16" |
 |
|
|
sassora
Starting Member
2 Posts |
Posted - 2008-01-29 : 18:22:05
|
| Thanks for your help |
 |
|
|
|
|
|