sgrgmngt
sgrgmngt

Reputation: 917

concatenation of decimal and varchar in SQL

I have 2 columns in my table :

PER_DAY (DECIMAL(10,2))
DESCP   (VARCHAR)

I want to concat the two columns in my query...

For Ex:

PER_DAY=0.5  DESCP='ABCDEFGHIJ'

I want them to be displayed as

0.5-ABCDEFGHIJ

I'm using IBM DB2.

Upvotes: 0

Views: 9518

Answers (2)

Dave Ford
Dave Ford

Reputation: 363

How about this:

select trim(varchar(per_day)) || '-' || DESCP from table;

Upvotes: 0

Yahia
Yahia

Reputation: 70379

have you tried

select char(per_day) || DESCP from table;

EDIT:

select CAST(per_day AS VARCHAR(13)) || '-' || DESCP from table;

Upvotes: 0

Related Questions