Link to home
Start Free TrialLog in
Avatar of fahVB
fahVB

asked on

Sql query Calculation error

Can someone please help me, this line in my query is throwing following error

Msg 8117, Level 16, State 1, Line 9
Operand data type varchar is invalid for multiply operator.
case when e.ytdintpaid = 0 then (e.currentintrate*e.currentprinbal*(30)/360) else convert(varchar, Cast(abs(e.ytdintpaid)/(3) as money)) end as AINTINC,

Open in new window

Avatar of openshac
openshac

One of you columns in not numeric, it's a varchar.

Work out which on it is and convert it using CONVERT()
another thing worth looking at is that your WHEN and ELSE return different datatype.

The column AINTINC has to have a consistent datatype across all parts of the CASE statement
Avatar of fahVB

ASKER

Test
Avatar of fahVB

ASKER

i made following changes and getting a diff error
Msg 245, Level 16, State 1, Line 9
Conversion failed when converting the varchar value '940.13' to data type int.

Avatar of fahVB

ASKER

this is with change

case when convert(varchar(20), e.ytdintpaid) = '0' then convert(varchar(20),e.currentintrate)*(convert(varchar(20),e.currentprinbal)*(30)/360) else convert(varchar(20), Cast(abs(e.ytdintpaid)/(3) as money)) end as AINTINC,
ASKER CERTIFIED SOLUTION
Avatar of openshac
openshac

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of fahVB

ASKER

Thank you, this way it worked, appreciate it