| Author |
Topic |
|
Chinni
Yak Posting Veteran
95 Posts |
Posted - 2008-08-25 : 11:12:50
|
| Can you plz help me in thisdeclare @amount NUMERIC(10,0)set @amount =(select income from incometable ) select case when (@amount IN ('NA','na','n/a','N/A')) then 'ACF' when (@amount = 0) then 'PT' else 'NA'endI declare @amount as numeric but i should pass characters ,how to cast Thanks |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-08-25 : 11:19:53
|
[code]SELECT CASE WHEN @Amount LIKE '%N%A%' THEN 'ACF' WHEN @Amount = 0 THEN 'PT' ELSE 'NA' END[/code] E 12°55'05.25"N 56°04'39.16" |
 |
|
|
Chinni
Yak Posting Veteran
95 Posts |
Posted - 2008-08-25 : 11:31:16
|
| thanks for your quick respnseI declare @ amount as numeric(10,0) and i am passing a character.....they asked me cast when i am doing this ......can you suggest me how to cast |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-08-25 : 11:33:17
|
No need to cast.declare @amount as varchar(2583)select @amount = income from incometableSELECT CASE WHEN @Amount LIKE '%N%A%' THEN 'ACF' WHEN @Amount = '0' THEN 'PT' ELSE 'NA' END E 12°55'05.25"N 56°04'39.16" |
 |
|
|
Chinni
Yak Posting Veteran
95 Posts |
Posted - 2008-08-25 : 11:54:35
|
| thanks a lot... |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-08-26 : 04:08:53
|
quote: Originally posted by Chinni Can you plz help me in thisdeclare @amount NUMERIC(10,0)set @amount =(select income from incometable ) select case when (@amount IN ('NA','na','n/a','N/A')) then 'ACF' when (@amount = 0) then 'PT' else 'NA'endI declare @amount as numeric but i should pass characters ,how to cast Thanks
How can you store these values 'NA','na','n/a','N/A' in a NUMERIC datatype variable?MadhivananFailing to plan is Planning to fail |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-08-26 : 04:21:35
|
He isn't.Also the set @amount = (select ...) thingy is flawed, but I saved that to another topic. E 12°55'05.25"N 56°04'39.16" |
 |
|
|
Transact Charlie
Master Smack Fu Yak Hacker
3451 Posts |
Posted - 2008-08-26 : 05:39:11
|
Chinni,I'm sure this isn't doing what you expect it to.The line select @amount = income from incometable Is actually assigning *each* entry in incometable to the variable 1 at a time in no set order so you end up with the *last* entry in the table (ordered in some arbitrary way by the server). Are you sure this is what you want? I don't think so.I think what you actually want is this.SELECT ic.<WHATEVER IDENTIFYING COLUMN EXISTS> , CASE WHEN ic.[income] IN ('NA','na','n/a','N/A') THEN 'ACF' WHEN ic.[income] = '0' THEN 'PT' ELSE 'NA' END AS [Income Type]FROM incometable icWhich will return a list of income Types with whatever other details you need. (replace the <WHATEVER IDENTIFYING COLUMN EXISTS> with your won columns)-------------Charlie |
 |
|
|
Transact Charlie
Master Smack Fu Yak Hacker
3451 Posts |
Posted - 2008-08-26 : 05:40:51
|
quote: Originally posted by Peso He isn't.Also the set @amount = (select ...) thingy is flawed, but I saved that to another topic. E 12°55'05.25"N 56°04'39.16"
Has he raised a duplicate post?-------------Charlie |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-08-26 : 06:19:08
|
No, not yet.But it will come soon...You explained why in your earlier post. E 12°55'05.25"N 56°04'39.16" |
 |
|
|
Transact Charlie
Master Smack Fu Yak Hacker
3451 Posts |
Posted - 2008-08-26 : 06:26:20
|
quote: Originally posted by Peso No, not yet.But it will come soon...You explained why in your earlier post. E 12°55'05.25"N 56°04'39.16"
hmmmm... Giving them exactly what they ask for, even though its probably not what they actually want... Bit of a hard lesson.I like it! Maybe I should delete my post and wait for the subsequent "Why it no work???? -- URGENT!!!" posts.-------------Charlie |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-08-26 : 07:19:06
|
I have noticed giving them too much information makes them nervous and not reading anything from the suggestions. E 12°55'05.25"N 56°04'39.16" |
 |
|
|
|