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.
Author |
Topic |
zeeshan13
Constraint Violating Yak Guru
347 Posts |
Posted - 2007-08-02 : 11:48:36
|
Hi All,I have a table called Table1. It has the following 2 fields and datatypes.scn_dol_am (decimal with precision 18 & scale 2)scn_unt_qy (BigInt)I am running the following simple select statement. select (scn_dol_am/scn_unt_qy) Price from Table1 Note that I am dividing the 2 fields and getting the result in the following format (following are some examples). 1.05000000000000000000001.34000000000000000000001.33333333333333333333331.85000000000000000000003.4900000000000000000000I want the above to be displayed as decimal with a scale of 2. Meaning I want it to be display as decimal rounded to 2 decimal place.How can I achieve this?.Thanks a million....Zee |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-08-02 : 11:55:41
|
select price, round(scn_dol_am/scn_unt_qy, 2), cast(scn_dol_am/scn_unt_qy as decimal(18,2))from Table1 E 12°55'05.25"N 56°04'39.16" |
 |
|
sshelper
Posting Yak Master
216 Posts |
Posted - 2007-08-02 : 11:56:27
|
Try CASTing the result to DECIMAL as follows:select CAST(scn_dol_am/scn_unt_qy AS DECIMAL(18, 2)) Price from Table1SQL Server Helperhttp://www.sql-server-helper.com |
 |
|
|
|
|