Thread: set decimal point in SQL

set decimal point in SQL

From
"Bu, Ning"
Date:
<img class="shape" height="0" src="cid:image001.jpg@01C33428.8D51A460" style="display:none;width:0;height:0"
v:shapes="_x0000_Mail"v:src="cid:image001.jpg@01C33428.8D51A460" width="0" /><div class="Section1"><p
class="MsoNormal"><fontcolor="black" face="sans serif" size="3"><span style="font-size:12.0pt"> </span></font><p
class="MsoNormal"><fontcolor="black" face="sans serif" size="3"><span style="font-size:12.0pt"> </span></font><p
class="MsoNormal"><b><i><fontcolor="navy" face="Book Antiqua" size="3"><span style="font-size:12.0pt;font-family:"Book
Antiqua";mso-bidi-font-family:"BookAntiqua"; 
color:navy;font-weight:bold;font-style:italic;mso-no-proof:yes">I have a field set up as money and I try to calculate
somenumber and put in this field, but the number will be 6 demical point and I want to cut it to only 2-4 decimal
point,how can I do it? Thanks</span></font></i></b></div> 

Re: set decimal point in SQL

From
Rodger Donaldson
Date:
On Mon, Jun 16, 2003 at 05:02:34PM -0500, Bu, Ning wrote:

> I have a field set up as money and I try to calculate some number
> and put in this field, but the number will be 6 demical point and I
> want to cut it to only 2-4 decimal point, how can I do it? Thanks

round(); eg

select    round(foo, 2)
from    bar

...will give you values in column foo rounded to 2 decimal places.

-- 
Rodger Donaldson        rodgerd@diaspora.gen.nz
I don't mind straight people, as long as they act gay in public


Re: set decimal point in SQL

From
Jeff Eckermann
Date:
--- Rodger Donaldson <rodgerd@diaspora.gen.nz> wrote:
> On Mon, Jun 16, 2003 at 05:02:34PM -0500, Bu, Ning
> wrote:
> 
> > I have a field set up as money and I try to
> calculate some number
> > and put in this field, but the number will be 6
> demical point and I
> > want to cut it to only 2-4 decimal point, how can
> I do it? Thanks
> 
> round(); eg
> 
> select    round(foo, 2)
> from    bar
> 
> ...will give you values in column foo rounded to 2
> decimal places.
> 

If you use "numeric(x,2)", where x is the largest
number of digits you are likely to need, the rounding
will be done for you.  Type "money" is deprecated
anyway, and is likely to be dropped in a future
release.  You can format the numeric value on output
if you want to display currency symbols or whatever.

__________________________________
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com