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 |
LOLCatLady
Starting Member
24 Posts |
Posted - 2010-07-27 : 12:03:35
|
This is probably a pretty basic question, but it's been a year and a half since I've worked with SQL so my brain has lost a lot.I am running a query to pull data within a range of codes: 3157 - 3174. I need to add a column that shows each of the codes in the range as a single code, preferably the first one 3157.How can I do this? (I used to know how, but I'm drawing a complete blank!) |
|
Sachin.Nand
2937 Posts |
Posted - 2010-07-27 : 12:06:30
|
select * from table where code between 3157 and 3174Limitations live only in our minds. But if we use our imaginations, our possibilities become limitless. PBUH |
 |
|
LOLCatLady
Starting Member
24 Posts |
Posted - 2010-07-27 : 12:19:58
|
quote: Originally posted by Idera select * from table where code between 3157 and 3174Limitations live only in our minds. But if we use our imaginations, our possibilities become limitless. PBUH
I have that. What I need to do is for each of the codes 3157 - 3174 I want another column where I can change them to all the same code. |
 |
|
Sachin.Nand
2937 Posts |
Posted - 2010-07-27 : 12:25:13
|
What do you mean by "same code"?Can you post some expected o/p.Limitations live only in our minds. But if we use our imaginations, our possibilities become limitless. PBUH |
 |
|
Lamprey
Master Smack Fu Yak Hacker
4614 Posts |
|
LOLCatLady
Starting Member
24 Posts |
Posted - 2010-07-27 : 12:53:42
|
quote: Originally posted by Idera What do you mean by "same code"?Can you post some expected o/p.Limitations live only in our minds. But if we use our imaginations, our possibilities become limitless. PBUH
For all the codes within the range 3157 - 3174, I want to rename them all to 3157: 3157 to 31573158 to 31573159 to 3157etc.My query will create a new table to do additional analysis, and it would make it easier to combine the ranges of codes. |
 |
|
Sachin.Nand
2937 Posts |
Posted - 2010-07-27 : 12:56:14
|
quote: Originally posted by LOLCatLady
quote: Originally posted by Idera What do you mean by "same code"?Can you post some expected o/p.Limitations live only in our minds. But if we use our imaginations, our possibilities become limitless. PBUH
For all the codes within the range 3157 - 3174, I want to rename them all to 3157: 3157 to 31573158 to 31573159 to 3157etc.My query will create a new table to do additional analysis, and it would make it easier to combine the ranges of codes.
select '3157' as code from table where code between 3157 and 3174Limitations live only in our minds. But if we use our imaginations, our possibilities become limitless. PBUH |
 |
|
LOLCatLady
Starting Member
24 Posts |
Posted - 2010-07-27 : 14:49:54
|
Perfect! That worked exactly how I needed it to. Thank you for your help! |
 |
|
Sachin.Nand
2937 Posts |
Posted - 2010-07-28 : 01:19:07
|
quote: Originally posted by LOLCatLady Perfect! That worked exactly how I needed it to. Thank you for your help!
Welcome Limitations live only in our minds. But if we use our imaginations, our possibilities become limitless. PBUH |
 |
|
|
|
|
|
|