Friday, March 30, 2012

Problem in getting result

I have an account field which has datatype string. I wantto onlyget thosevalues which areinbetween 0-199.

I used

selectsum(t.a_trans_amt) Creditfrom a_account a, a_transaction t

where a.a_account_numbetween'0'and'199'

and

t.a_account_id=a.a_account_id

and t.a_debit_credit_ind='C'

but this query also including thosevalues which have starting 3 digitinbetween 0-199.

I don't know how to fix this problem . Can anybody help me on this issue.

Thanks in Advance.

What about a convert:

WHEREConvert(int,a.a_account_num)between 0and 199

|||

i tried it but it gave me this error

Error converting data type varchar to bigint.

i think becoz some '-' is there in the name

|||

When you do a string comparison, you get what you have now. If you want to use integer to compare, you need to show all your data patterns. You can remove the hyphen if you think that will get correct result. Just post some of your data and let's see what we can do for you.

No comments:

Post a Comment