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.
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,
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
The column AINTINC has to have a consistent datatype across all parts of the CASE statement
ASKER
Test
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.
Msg 245, Level 16, State 1, Line 9
Conversion failed when converting the varchar value '940.13' to data type int.
ASKER
this is with change
case when convert(varchar(20), e.ytdintpaid) = '0' then convert(varchar(20),e.curr entintrate )*(convert (varchar(2 0),e.curre ntprinbal) *(30)/360) else convert(varchar(20), Cast(abs(e.ytdintpaid)/(3) as money)) end as AINTINC,
case when convert(varchar(20), e.ytdintpaid) = '0' then convert(varchar(20),e.curr
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you, this way it worked, appreciate it
Work out which on it is and convert it using CONVERT()