Solved

How to change several decimal digits into 2

Posted on 2008-10-01
5
182 Views
Last Modified: 2012-05-05
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
Comment
Question by:fahVB
  • 2
  • 2
5 Comments
 
LVL 39

Expert Comment

by:BrandonGalderisi
ID: 22618748
cast(case when e.interestrate = 0 then 0 else abs(l.fin_chrg/(e.interestrate/12)) end ) as decimal(6,2)) as AAVGBALA
0
 
LVL 7

Expert Comment

by:aboredman
ID: 22618750
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 Comment

by:fahVB
ID: 22618790
getting this error

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

Accepted Solution

by:
BrandonGalderisi earned 500 total points
ID: 22619140
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 Closing Comment

by:fahVB
ID: 31502158
Cool, thanks
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

INTRODUCTION: While tying your database objects into builds and your enterprise source control system takes a third-party product (like Visual Studio Database Edition or Red-Gate's SQL Source Control), you can achieve some protection using a sing…
In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question