Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

sql query to find fractional part as it is and not rounded

teefu ghulamApr 17 2018 — edited Apr 19 2018

dear members,

i am using Oracle db 10g

my query: how to separate whole number and fraction

e.g. if the figure is 1503.006 then the result should be like 1503 and 0.006

run script to load data.

CREATE TABLE tab_a

    (wt  NUMBER(10,3)

    )

/

INSERT INTO tab_a

(WT)

VALUES

(1557.54)

/

INSERT INTO tab_a

(WT)

VALUES

(1556.653)

/

INSERT INTO tab_a

(WT)

VALUES

(1555.768)

/

INSERT INTO tab_a

(WT)

VALUES

(1554.883)

/

INSERT INTO tab_a

(WT)

VALUES

(1553.118)

/

INSERT INTO tab_a

(WT)

VALUES

(1552.236)

/

INSERT INTO tab_a

(WT)

VALUES

(1551.356)

/

INSERT INTO tab_a

(WT)

VALUES

(1550.476)

/

INSERT INTO tab_a

(WT)

VALUES

(1549.598)

/

COMMIT

/

SELECT a.wt, FLOOR(a.wt) fl, a.wt-FLOOR(a.wt) fraction

  FROM tab_a a

  /

here when i run this statement i get FRACTION as rounded off to one decimal place. i want the WT column fractional part as it is. and after separation of fractional part, which fraction is the minimum.

thanks.

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 17 2018
Added on Apr 17 2018
6 comments
4,118 views