| Author |
Topic |
|
Archan144
Starting Member
4 Posts |
Posted - 2011-11-02 : 10:24:00
|
| I want to round value to 1 decimal place and show one 0 if decimal points has 00 after decimal.SELECT ROUND(124.000, 1) return 124.000 but I want 124.0andSELECT ROUND(124.2566, 1) returns 124.3000 but I want 124.3Can I get this in sql? |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-11-02 : 10:33:12
|
| what you're looking after isSELECT CAST(124.2566 AS decimal(10,1)) ...------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
Archan144
Starting Member
4 Posts |
Posted - 2011-11-02 : 11:03:42
|
Thanks for the quick reply, here we are adding restiction to have value of 10 digits which I can't give becuase it's not fixed.Is there alternate way ?quote: Originally posted by visakh16 what you're looking after isSELECT CAST(124.2566 AS decimal(10,1)) ...------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/
|
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-11-02 : 11:05:10
|
quote: Originally posted by Archan144 Thanks for the quick reply, here we are adding restiction to have value of 10 digits which I can't give becuase it's not fixed.Is there alternate way ?quote: Originally posted by visakh16 what you're looking after isSELECT CAST(124.2566 AS decimal(10,1)) ...------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/
what does that mean? if you want one decimal place why cant you have a fixed scale?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
Archan144
Starting Member
4 Posts |
Posted - 2011-11-02 : 11:25:19
|
Below query gives error on execution SELECT CAST(1245678912.000 AS decimal(10,1)) while SELECT CAST(124567891.000 AS decimal(10,1)) this works because 124567891 are 10 digits and if we exceed that then it blows up. So I can give fix scale as 1 which I want but that limit of 10 I can't impose.Thanks in advance.quote: Originally posted by visakh16
quote: Originally posted by Archan144 Thanks for the quick reply, here we are adding restiction to have value of 10 digits which I can't give becuase it's not fixed.Is there alternate way ?quote: Originally posted by visakh16 what you're looking after isSELECT CAST(124.2566 AS decimal(10,1)) ...------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/
what does that mean? if you want one decimal place why cant you have a fixed scale?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/
|
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-11-02 : 11:39:41
|
| then give a bigger limit. may be 25------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
Archan144
Starting Member
4 Posts |
Posted - 2011-11-03 : 09:52:59
|
Yes, that can be done. Thanks.quote: Originally posted by visakh16 then give a bigger limit. may be 25------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/
|
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-11-03 : 10:08:46
|
| wc------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|