How to get integer portion from a decimal (4 Megred) [message #544448] |
Tue, 21 February 2012 20:21  |
 |
VINORACLE
Messages: 14 Registered: September 2011 Location: Calgary
|
Junior Member |
|
|
Hi friends,
I hope you will be abale to help me on this as in the previous occations.
Using Oracle SQL Developer 2.1.1.64 to run the queries & Oracle 11g.
I have two numbers in two colomns of an oracle table(colomn a & colomn b). I am trying to divide colomn a/colomn b and putting the results in colomn c & also in colomn d (all in the same table) using update commands
Eg: UPDATE MTOTABLE_PWELD pw SET pw.WELDO=(pw.pipe_length/12000);
But here is the real issue. In colomn d I only need the integer portion of the division value.
For example , when I divide colomn a/colomn b , let us assume that we are getting a value of 2.56. Then I want the value of 2 to go to colomn d.
I tried round((colomn a/colomn b),0). But it rounds off 2.56 to 3.
I dont want that. I need the exact integer portion of the value to be seperated.
Pl help
Regards,
Vinod
|
|
|
|
Re: How to get integer portion from a decimal [message #544454 is a reply to message #544452] |
Tue, 21 February 2012 22:25  |
 |
Barbara Boehmer
Messages: 9106 Registered: November 2002 Location: California, USA
|
Senior Member |
|
|
SCOTT@orcl_11gR2> CREATE TABLE mtotable_pweld
2 (pipe_length NUMBER,
3 b NUMBER,
4 weldo NUMBER)
5 /
Table created.
SCOTT@orcl_11gR2> INSERT INTO mtotable_pweld VALUES (30720, 12000, NULL)
2 /
1 row created.
SCOTT@orcl_11gR2> SELECT * FROM mtotable_pweld
2 /
PIPE_LENGTH B WELDO
----------- ---------- ----------
30720 12000
1 row selected.
SCOTT@orcl_11gR2> UPDATE mtotable_pweld
2 SET weldo = TRUNC (pipe_length / b)
3 /
1 row updated.
SCOTT@orcl_11gR2> SELECT * FROM mtotable_pweld
2 /
PIPE_LENGTH B WELDO
----------- ---------- ----------
30720 12000 2
1 row selected.
SCOTT@orcl_11gR2>
|
|
|