?
Solved

query

Posted on 2014-03-04
4
Medium Priority
?
201 Views
Last Modified: 2014-05-28
I have a data something like below:

mycol
---------
xyzmap
xyzjob1
xyztab2
xyztime
abcledger
abclicense
abctime
abcmap
pqrmap
pqrlinked
pqrtime

i want to derive a column where the value %map repeats for each group(abc, xyz,pqr)

mycol             mydercol
---------           -------------
xyzmap          xyzmap
xyzjob1          xyzmap
xyztab2          xyzmap
xyztime         xyzmap
abcledger      abcmap
abclicense    abcmap
abctime        abcmap
abcmap        abcmap
pqrmap        pqrmap
pqrlinked     pqrmap
pqrtime        pqrmap

is there a way to do this..

thanks
0
Comment
Question by:gs79
[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
4 Comments
 
LVL 22

Assisted Solution

by:Ivo Stoykov
Ivo Stoykov earned 500 total points
ID: 39905648
it is not clear what do you mean by 'each group' but you could try this
SELECT substr(mycol, 1, 3) || 'map' mydercol FROM mytable

Open in new window

HTH
Ivo Stoykov
0
 
LVL 41

Assisted Solution

by:Sharath
Sharath earned 500 total points
ID: 39905656
try like this.
select t1.MyCol,t2.mydercol
  from test t1,
(select MyCol as mydercol,replace(MyCol,'map','') as MyCol1
  from test
 where MyCol like '%map') t2 where t1.MyCol like t2.MyCol1||'%'

Open in new window

http://sqlfiddle.com/#!4/408e1/9
0
 
LVL 35

Accepted Solution

by:
Mark Geerlings earned 500 total points
ID: 39908337
Is it always the first three characters that determines your "%map"?  If yes, then a simple query like this can do that for you: substr(mycol,1,3)||'map'.

You could create a view like this:
create or replace view map_view
(mycol, mydircol)
as select mycol, substr(mycol,1,3)||'map'
from your_table;
0
 
LVL 32

Assisted Solution

by:awking00
awking00 earned 500 total points
ID: 39920925
gs79,
You need to confirm or refute that the "group" is always the first three characters. If so, the concatenation already shown should work. If not, the task becomes a little more complex and will require further criteria for determining the "group".
0

Featured Post

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

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

Working with Network Access Control Lists in Oracle 11g (part 2) Part 1: http://www.e-e.com/A_8429.html Previously, I introduced the basics of network ACL's including how to create, delete and modify entries to allow and deny access.  For many‚Ķ
Shell script to create broker configuration file using current broker Configuration, solely for purpose of backup on Linux. Script may need to be modified depending on OS-installation. Please deploy and verify the script in a test environment.
This video explains at a high level with the mandatory Oracle Memory processes are as well as touching on some of the more common optional ones.
This video shows how to configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.

777 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