x

concatenation of decimal and varchar

Hello i am using IBM db2. 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.
more ▼

asked Jul 31, 2011 at 11:35 PM in Default

sagar 2 gravatar image

sagar 2
111 6 8 9

(comments are locked)
10|1200 characters needed characters left

1 answer: sort voted first
I found it...I used concat(concat(rtrim(char(int(PER_DAY))), '.'), rtrim(right(char(PER_DAY - int(PER_DAY)), 3)))
more ▼

answered Jul 31, 2011 at 11:49 PM

sagar 2 gravatar image

sagar 2
111 6 8 9

Well done on finding your answer, and thank you for posting it for other people having the same problem. Could you please mark the answer as 'accepted' in order that we can all see from the main page that your problem is resolved?
Aug 01, 2011 at 12:40 AM Dave_Green ♦
(comments are locked)
10|1200 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

New code box

There's a new way to format code on the site - the red speech bubble logo will automatically format T-SQL for you. The original code box is still there for XML, etc. More details here.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

SQL Server Central

Need long-form SQL discussion? SQLserverCentral.com is the place.

Topics:

x19

asked: Jul 31, 2011 at 11:35 PM

Seen: 1470 times

Last Updated: Jul 31, 2011 at 11:35 PM