Avatar of Prardhan N
Prardhan NFlag for India

asked on 

Need help on Type casting and removing of leading and trailing Zeros for amount column(Decimal) in DB2

Need help on Type casting and removing of leading and trailing Zeros for amount column(Decimal) in DB2.

select cast(amount as VARCHAR(4000 OCTETS)) from schemaname.tablename where pay_id=1038 with ur ;

Casting function is not removing the trailing zeros.

Can you please suggest how to remove the leading and trailing zeros.

Thanks in advance!!!
DB2

Avatar of undefined
Last Comment
Prardhan N
Avatar of Pawan Kumar
Pawan Kumar
Flag of India image

Please try BIGINT

select CAST(cast(amount as VARCHAR(4000 OCTETS)) AS BIGINT) from schemaname.tablename where pay_id=1038 with ur ;
ASKER CERTIFIED SOLUTION
Avatar of Pawan Kumar
Pawan Kumar
Flag of India image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of Pawan Kumar
Pawan Kumar
Flag of India image

Another option could be-

select  TRIM( 'T',0, TRIM( 'L' ,0, CAST( amount as VARCHAR(4000 OCTETS) ) ) )
from schemaname.tablename where pay_id=1038 with ur ;
Avatar of Prardhan N
Prardhan N
Flag of India image

ASKER

Thanks for inputs. working on inputs.
Avatar of Prardhan N
Prardhan N
Flag of India image

ASKER

Thanks for help!!!
DB2
DB2

IBM DB2 is a family of relational database server products developed by IBM that have been extended to support object-relational features and non-relational structures like JSON and XML. There are three main products in the DB2 family: DB2 for Linux, UNIX and Windows (informally known as DB2 LUW), DB2 for z/OS (mainframe), and DB2 for i (formerly OS/400), plus a version for IBM's Virtual Storage Extended (VSE) operating system.

6K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo