x
login about faq Site discussion (meta-askssc)

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 '11 at 11:35 PM in Default

sagar 2 gravatar image

sagar 2
111 2 6 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 '11 at 11:49 PM

sagar 2 gravatar image

sagar 2
111 2 6 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 '11 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.

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



Facebook logo Follow Ask SSC on Facebook
Find Ask SSC on Google+
linkedin logo Find us on LinkedIn

Topics:

x16

asked: Jul 31 '11 at 11:35 PM

Seen: 784 times

Last Updated: Jul 31 '11 at 11:35 PM

Copyright © 2002-2012 Simple Talk Publishing. All Rights Reserved. If you have any queries, please contact the site administrators.
Ask SQL Server Central is a community service provided by Red Gate.