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.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 addition of columen

Author  Topic 

acdacd
Yak Posting Veteran

63 Posts

Posted - 2005-08-17 : 08:57:28
Dear all,
It work!
select Case lang1
when 'Chinese' then 10
else 20
end as abc,

lang1spoken,

([ID]*2 + Convert(int, lang1spoken))
from Job_Req_lang

It fail
select Case lang1
when 'Chinese' then 10
else 20
end as abc,

lang1spoken,

([ID]*2 + Convert(int, abc))
from Job_Req_lang

What is the problem?
How to solve it?

be a hardworking people!!

Kristen
Test

22859 Posts

Posted - 2005-08-17 : 09:03:18
What error are you seeing?

What data type is "abc"? Perhaps it does not contain bvalid INTs?

Kristen
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-08-17 : 09:03:33
You need to use derived table
Select abc,([ID]*2 + Convert(int, abc)) from(
select [ID],Case lang1 when 'Chinese' then 10 else 20 end as abc, lang1spoken
from Job_Req_lang) T


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

acdacd
Yak Posting Veteran

63 Posts

Posted - 2005-08-17 : 09:20:02
Thx
The problem is that the abc is the orginal col name of table, derived Table solve this problem

be a hardworking people!!
Go to Top of Page
   

- Advertisement -