Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Decimal places

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2003-12-30 : 12:07:18
Nadia writes "Hi...I want to display a number result using a spesific format with specific decimal places for example
Select (amt1+amt2+amt3-amt4) as [app amt]
I get 590 as app amt but I want the result to be 590.000 with 3 decimal plaes and if the result is not integer like 590.088888886 I want it to be again with 3 decimal places 590.088
so I want the number with 3 decimal places

I tried decimal and cast function it worked for me only with the number contains decimal but when the number is integer didn't work for me

any idea?
thanks"

Sitka
Aged Yak Warrior

571 Posts

Posted - 2003-12-30 : 12:17:35
Select CAST((amt1+amt2+amt3-amt4) as numeric(10,3)) as [app amt]

ex SELECT CAST((1+1.75+1.65432-6) AS numeric(10,3)) as [app amt]


They make a grunting sound when agitated, hungry, or calling their young. Otherwise, they make no sound at all.
Go to Top of Page

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2003-12-30 : 13:02:39
do this at the presentation layer, not the database layer.

- Jeff
Go to Top of Page
   

- Advertisement -