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 remove a decimal using SQL Query?

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

New User


Joined: 24 Nov 2009
Posts: 37
Location: Don't know

PostPosted: Sat May 26, 2012 6:29 pm    Post subject: How to remove a decimal using SQL Query?
Reply with quote

ICD9
CD
-------
695.1
940
940.0

should be modified to

ICD9
CD
-------
6951
940
9400

Can this be handled through a SQL Query?
Back to top
View user's profile Send private message

dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Sat May 26, 2012 6:56 pm    Post subject:
Reply with quote

how are we to provide any guidance,
when you don't bother to provide us the ddl for the column?

as a side note, going from
695.1 to 9651 is times 10
940 to 940 is times 1
940.0 to 9400 is times 10

what kind of rules do you have?
but then again, that sorta depends on the datatype of the column
which you have neglected to provide.........................

so at this point, there is nothing we can do to help
Back to top
View user's profile Send private message
santoshkumarmanilakkoju

New User


Joined: 24 Nov 2009
Posts: 37
Location: Don't know

PostPosted: Sat May 26, 2012 7:19 pm    Post subject: Reply to: How to remove a decimal using SQL Query?
Reply with quote

Sorry for the incomplete information -

Below is the declaration of the field -
ICD9_CD CHAR(7) NOT NULL WITH DEFAULT

The decimal as such can be at any position in all 7 bytes. Can a SQL query remove it?

Examples for better understanding -

Current --> Modified
12345.7 --> 123457
1234.67 --> 123467
123.567 --> 123567
12.4567 --> 124567
1.34567 --> 134567
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Sat May 26, 2012 7:39 pm    Post subject:
Reply with quote

look up the REPLACE function in the manual.
Back to top
View user's profile Send private message
santoshkumarmanilakkoju

New User


Joined: 24 Nov 2009
Posts: 37
Location: Don't know

PostPosted: Sun May 27, 2012 9:56 am    Post subject:
Reply with quote

Below is what I did and it worked. Thank you Bren...!

Code:
UPDATE TABLE.NAME                           
SET ICD9_CD=SUBSTR(REPLACE(ICD9_CD,'.',''),1,7)
WHERE ICD9_CD != ' '; 
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Sun May 27, 2012 10:30 am    Post subject:
Reply with quote

glad t help. good implementation.
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 Join in SQL Query vickey_dw DB2 2 Tue Jan 17, 2017 12:15 am
This topic is locked: you cannot edit posts or make replies. MQ setup query mohitsaini Java & MQSeries 4 Sun Jan 08, 2017 1:53 am
No new posts DB2 query Using Recursion, Converting... smilewithashu2 DB2 1 Tue Jan 03, 2017 12:50 pm
No new posts SQL query to run through list of valu... Ni3-db2 DB2 14 Wed Dec 14, 2016 9:52 am
This topic is locked: you cannot edit posts or make replies. Db2 SQL query to convert rows into co... subratarec DB2 5 Thu Nov 17, 2016 4:51 pm


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