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 |
|
mike123
Master Smack Fu Yak Hacker
1462 Posts |
Posted - 2008-10-14 : 13:36:29
|
| Hi,I have a query as suchSELECT 'string' + rank + 'aboutTheRank' FROM tbl I want to modify it so that , depending on the value of rank, we append an appropriate string after it. There are just 2 different possible values (1,2)How can I do this ? For example below is what I want to accompish, but not the right syntax obviously .. Thanks for any tips!mike123IF rank =1SELECT 'string' + rank + 'aboutTheRank1' FROM tbl If rank =2 SELECT 'string' + rank + 'aboutTheRank2' FROM tbl |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-10-14 : 13:38:57
|
use thisSELECT 'string' + rank + case when rank=1 then 'aboutTheRank1' else 'aboutTheRank2' end FROM tbl |
 |
|
|
mike123
Master Smack Fu Yak Hacker
1462 Posts |
Posted - 2008-10-14 : 13:50:47
|
| perfect, thank you ! :) |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-10-14 : 13:52:43
|
quote: Originally posted by mike123 perfect, thank you ! :)
welcome |
 |
|
|
|
|
|