• Status: Solved
• Priority: Medium
• Security: Public
• Views: 191

# How to change several decimal digits into 2

I am using this function, it is working but i am getting several decimal digits, any way i can change it two

case when e.interestrate = 0 then 0 else abs(l.fin_chrg/(e.interestrate/12)) end as AAVGBALA

result
13.8030303030303

0
fahVB
• 2
• 2
1 Solution

Commented:
cast(case when e.interestrate = 0 then 0 else abs(l.fin_chrg/(e.interestrate/12)) end ) as decimal(6,2)) as AAVGBALA
0

Commented:
The easiest way is often to:

1. Multiply by 100
2. convert to integer (round to the nearest multiple of 1)
3. Convert to Decimal
4. Divide by 100.
0

Author Commented:
getting this error

Msg 1035, Level 15, State 10, Line 18
Incorrect syntax near 'cast', expected 'AS'.
0

Commented:
Sorry... one too many )

cast(case when e.interestrate = 0 then 0 else abs(l.fin_chrg/(e.interestrate/12)) end as decimal(6,2)) as AAVGBALA
0

Author Commented:
Cool, thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.