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 |
|
turbohao
Starting Member
3 Posts |
Posted - 2009-11-30 : 09:09:19
|
| greetingsI try to convert an integer to a decimal value COUNT(book_id) from booksi have a value 6,i want to have 6.00i try to convert it withCAST(count(book_id) as DECIMAL(1,2)) FROM booksdoes anyone know the correct syntax? |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-11-30 : 09:15:41
|
| 1 count(book_id)*1.002 CAST(count(book_id) as DECIMAL(12,2))MadhivananFailing to plan is Planning to fail |
 |
|
|
rajdaksha
Aged Yak Warrior
595 Posts |
Posted - 2009-11-30 : 09:16:14
|
| HiCOUNT always returns an int data type value.-------------------------R... |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2009-11-30 : 09:31:10
|
To make it more clear:6.00 would be DECIMAL(3,2)1000.9 would be DECIMAL(5,1)125.345 would be DECIMAL(6,3)So DECIMAL(1,2) is not possible. No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-11-30 : 09:34:52
|
| yeah as DECIMAL (p,s) represents value with p precision (total number of digits p) and scale s (number of digits after decimal point s) |
 |
|
|
turbohao
Starting Member
3 Posts |
Posted - 2009-12-01 : 04:31:09
|
| thanks for the explenation :) |
 |
|
|
|
|
|