Home » SQL & PL/SQL » SQL & PL/SQL » cast-ing question
cast-ing question [message #229976] Tue, 10 April 2007 08:13 Go to next message
pithhelmet
Messages: 1
Registered: April 2007
Junior Member
Hi everyone -

I have a query that returns a (i assume) is a float....

but i need to reduce the precision of the number.

what is the syntax to perform a cast on a query???

here is the query line


SELECT ST_Area(shape) / 43560 as acres FROM LRCREATOR.BURN_UNIT_BNDY WHERE BURN_UNIT_BNDY_ID = 13

Acres is returned as
117.47789100757139577594123048668503214

all i need is .xxx precision

thanks
tony
Re: cast-ing question [message #229981 is a reply to message #229976] Tue, 10 April 2007 08:22 Go to previous messageGo to next message
JRowbottom
Messages: 5933
Registered: June 2006
Location: Sunny North Yorkshire, ho...
Senior Member
You need the CAST command:
SQL> select cast(123.456789 as number(6,2)) num_col
  2  from   dual;

   NUM_COL
----------
    123.46

SQL> create table temp_cast as (select cast(123.456789 as number(6,2)) num_col
  2  from   dual);

Table created.

SQL> desc temp_cast;
 Name                                                  Null?    Type
 ----------------------------------------------------- -------- ------------------------------------
 NUM_COL                                                        NUMBER(6,2)
Re: cast-ing question [message #229982 is a reply to message #229976] Tue, 10 April 2007 08:23 Go to previous messageGo to next message
shanthkumaar
Messages: 156
Registered: February 2007
Location: india,chennai
Senior Member

hi,


too slow........ Embarassed .

regards
shanth

[Updated on: Tue, 10 April 2007 08:25]

Report message to a moderator

Re: cast-ing question [message #230069 is a reply to message #229976] Tue, 10 April 2007 16:04 Go to previous message
Bill B
Messages: 1484
Registered: December 2004
Senior Member
when you are reducing the precision, do you really want to truncate or do you want to round. Is it more accurate to say that 3.3456 should be set to 3.345 or should it be set to 3.346? If it's rounding you want then

SELECT round(ST_Area(shape) / 43560,3) as acres FROM LRCREATOR.BURN_UNIT_BNDY WHERE BURN_UNIT_BNDY_ID = 13
Previous Topic: Joins
Next Topic: Update Statement
Goto Forum:
  


Current Time: Sat Dec 10 22:30:50 CST 2016

Total time taken to generate the page: 0.10759 seconds