Solved

Oracle SQL query - Concatenate text to specific field value issue

Posted on 2014-11-09
2
359 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Cursors in Oracle: A cursor is used to process individual rows returned by database system for a query. In oracle every SQL statement executed by the oracle server has a private area. This area contains information about the SQL statement and the…
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…
Via a live example show how to connect to RMAN, make basic configuration settings changes and then take a backup of a demo database
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.

738 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