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 |
|
henrikop
Constraint Violating Yak Guru
280 Posts |
Posted - 2003-03-11 : 09:43:45
|
| I have a query which returns10674.54634 9565.49000 98216562.456I want my output to be with only (and always) two decimals, thus:10674.55 9565.49 982.0016562.46English is not my native language and I can't find it in BOL nor this forum. I have to do this in SQL, because I have no influence on the front end application.Thx, for the help!Henri~~~SQL is nothing, writing it everything. |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2003-03-11 : 10:04:38
|
| You can use CONVERT:SELECT Convert(decimal(12,2), myCol) FROM myTableCAST:SELECT CAST(myCol AS decimal(12,2)) FROM myTableOr the STR function:SELECT LTRIM(Str(myCol,12,2)) FROM myTableSTR() will output a string, padded on the left with spaces. The LTRIM will remove the spaces if you want, otherwise you can remove the LTRIM and you'll have nicely formatted numbers aligned on the right side. |
 |
|
|
henrikop
Constraint Violating Yak Guru
280 Posts |
Posted - 2003-03-11 : 11:18:24
|
| Thx for supplying 3 solutions! They have small differences. The third looks better, but in Holland we use , instead of . for numbers, and the third solution gives .'s which looks better, but gives weird outcomes in the webform.Henri~~~SQL is nothing, writing it everything. |
 |
|
|
|
|
|
|
|