Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

how to get only the number part and avoid the decimal part..

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
pjnithin

Active User


Joined: 22 Dec 2005
Posts: 116

PostPosted: Tue Jul 10, 2007 12:35 pm    Post subject: how to get only the number part and avoid the decimal part..
Reply with quote

how to avoid the decimal part while selecting a field which is declared to have decimals in db2
Back to top
View user's profile Send private message

sandeep1dimri

New User


Joined: 30 Oct 2006
Posts: 76

PostPosted: Tue Jul 10, 2007 1:07 pm    Post subject:
Reply with quote

May be this will help

SELECT SUBSTR(CHAR(ur-decimal-variable),1,10)
From ur-table
where conditions

Note: I have consider the decimal variable Decimal(11,2).

Sandeep
Back to top
View user's profile Send private message
vijaysharma

New User


Joined: 04 Jul 2007
Posts: 3
Location: Bangalore

PostPosted: Tue Jul 10, 2007 2:52 pm    Post subject: May be this will help
Reply with quote

Just adding to previous one...........

SELECT SUBSTR(CHAR(table-variable),1,10) INTO
: host-variable
FROM ur-table
WHERE conditions
Back to top
View user's profile Send private message
Raphael Bacay

New User


Joined: 04 May 2007
Posts: 58
Location: Manila, Philippines

PostPosted: Fri Aug 03, 2007 10:03 am    Post subject:
Reply with quote

Hi!


I just found that in SQL you can do this so maybe it is applicable to your problem.

SELECT FLOOR(column name) INTO
:host variable
FROM table
WHERE ...

*FLOOR function will return the non-decimal part of a digit.


Regards.
Back to top
View user's profile Send private message
Alan Voss

New User


Joined: 29 Nov 2006
Posts: 32
Location: Jacksonville, FL

PostPosted: Fri Aug 03, 2007 7:06 pm    Post subject:
Reply with quote

Be sure that floor is what you want, rather than integer:

    select A.I,
    integer(A.i) as I_INT,
    floor(A.I) as I_FLOORED
    from DECIMALS as A
    order by A.i;
    completed successfully.

    I I_INT I_FLOORED
    ------ ----------- ---------
    -5.00 -5 -5
    -4.75 -4 -5
    -4.50 -4 -5
    -4.25 -4 -5
    -4.00 -4 -4
    -3.75 -3 -4
    -3.50 -3 -4
    -3.25 -3 -4
    -3.00 -3 -3
    -2.75 -2 -3
    -2.50 -2 -3
    -2.25 -2 -3
    -2.00 -2 -2
    -1.75 -1 -2
    -1.50 -1 -2
    -1.25 -1 -2
    -1.00 -1 -1
    -0.75 0 -1
    -0.50 0 -1
    -0.25 0 -1
    0.00 0 0
    0.25 0 0
    0.50 0 0
    0.75 0 0
    1.00 1 1
    1.25 1 1
    1.50 1 1
    1.75 1 1
    2.00 2 2
    2.25 2 2
    2.50 2 2
    2.75 2 2
    3.00 3 3
    3.25 3 3
    3.50 3 3
    3.75 3 3
    4.00 4 4
    4.25 4 4
    4.50 4 4
    4.75 4 4
    5.00 5 5

    41 rows selected in 0.07 secs.

Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Fri Aug 03, 2007 7:33 pm    Post subject:
Reply with quote

Good catch icon_smile.gif
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts RMM: scratching a volume that RMM thi... Hervey Martinez IBM Tools 0 Mon May 15, 2017 8:51 pm
No new posts SMTP the current generation number of... Jyothi Kulunde JCL & VSAM 4 Thu May 04, 2017 4:08 pm
No new posts Edit large number of datasets (QSAM) zh_lad TSO/ISPF 3 Tue Apr 04, 2017 6:08 pm
No new posts how to mask the phone number kumarinfy DB2 4 Mon Apr 03, 2017 5:23 pm
No new posts what is meaning of the number in dcl Martylin PL/I & Assembler 2 Thu Mar 09, 2017 7:18 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us