Solved

Oracle SQL query - Concatenate text to specific field value issue

Posted on 2014-11-09
2
344 Views
Last Modified: 2014-11-09
Hi

I would like to know how i can add text to my field result when i'm runing an SQL.

Ex:
Select Case
when ID = '1' then ('TEST_' + ID)
when ID = '2' then ('NO_TEST_' + ID)
end from location;

Open in new window


So if my ID = 1 then i want to add the text "TEST_" just before the value 1.

How can i do this?

Thanks again
0
Comment
Question by:Wilder1626
2 Comments
 
LVL 15

Accepted Solution

by:
Haris Djulic earned 500 total points
ID: 40431542
Here is the code:

Select Case
when ID = '1' then ('TEST_' || value)
when ID = '2' then ('NO_TEST_' || value)
else value
end from location;

Open in new window


You can test it here http://sqlfiddle.com/#!4/d6b56/4
0
 
LVL 11

Author Closing Comment

by:Wilder1626
ID: 40431581
Thanks for your help.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Background In several of the companies I have worked for, I noticed that corporate reporting is off loaded from the production database and done mainly on a clone database which needs to be kept up to date daily by various means, be it a logical…
From implementing a password expiration date, to datatype conversions and file export options, these are some useful settings I've found in Jasper Server.
This video explains at a high level about the four available data types in Oracle and how dates can be manipulated by the user to get data into and out of the database.
Via a live example, show how to take different types of Oracle backups using RMAN.

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now