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 |
|
new_user
Starting Member
3 Posts |
Posted - 2007-05-14 : 15:58:53
|
| I have dept_code_tab table with dept_code likeFIN001FIN002PAY006first three letter represent the departmentI want a query that disaplays likeFIN001 FinanceFIN002 FinancePAY006 PAyRollMy case statement is not working. How to do this?select case dept_code when substring(dept_code,1,3) = 'FIN' then 'Finance' else 'others' from dept_code_tab |
|
|
jsmith8858
Dr. Cross Join
7423 Posts |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-05-14 : 16:02:03
|
| select case substring(dept_code, 1, 3) when 'FIN' then 'Finance' when 'pay' then 'Payroll' else 'others' endfrom dept_code_tab Peter LarssonHelsingborg, Sweden |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-05-15 : 09:32:00
|
orselect case when dept_code like 'FIN%' then 'Finance' when dept_code like 'pay%' then 'Payroll' else 'others' endfrom dept_code_tab MadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|