Solved

query

Posted on 2014-03-04
4
200 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 125 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 125 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 125 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 125 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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

I remember the day when someone asked me to create a user for an application developement. The user should be able to create views and materialized views and, so, I used the following syntax: (CODE) This way, I guessed, I would ensure that use…
This post first appeared at Oracleinaction  (http://oracleinaction.com/undo-and-redo-in-oracle/)by Anju Garg (Myself). I  will demonstrate that undo for DML’s is stored both in undo tablespace and online redo logs. Then, we will analyze the reaso…
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
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.

688 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