Getting parent-child data from a single column in a table

Hi,
I have a parent-child data in a column.
Eg:
0
00
01
010
011
1
10
11
These values are present in the single column itself. My need is to get the parent values for the given child value.
For eg: If I am giving the input as 011, the query should return all its parents, i.e. 01 and 0
Could you please give me any inputs on this?
Thanks,
GV

Frank Kulash wrote:
Assuming that each child's id is formed by adding exactly one character to the end of its parent's id:
SELECT     id
FROM     table_x
START WITH     id          = :target_id
CONNECT BY     PRIOR id     LIKE id || '_';
Small tweak to yours Frank if it's just the parents that need identifying...
SQL> ed
Wrote file afiedt.buf
  1  with t as (select '0' as x from dual union all
  2             select '00' from dual union all
  3             select '01' from dual union all
  4             select '010' from dual union all
  5             select '011' from dual union all
  6             select '1' from dual union all
  7             select '10' from dual union all
  8             select '11' from dual)
  9  -- end of test data
10  SELECT     x
11  FROM       t, (select '&required' as req from dual) req
12  WHERE x != req.req
13  START WITH x = req.req
14* CONNECT BY PRIOR x LIKE x || '_'
SQL> /
Enter value for required: 011
old  11: FROM   t, (select '&required' as req from dual) req
new  11: FROM   t, (select '011' as req from dual) req
X
01
0
SQL> /
Enter value for required: 11
old  11: FROM   t, (select '&required' as req from dual) req
new  11: FROM   t, (select '11' as req from dual) req
X
1
SQL>

Similar Messages

  • Getting parent-child data into an Oracle level-based OLAP hierarchy

    We have some organisational data which we need to represent in an Oracle OLAP 10g dimension, preferably populated using Warehouse Builder.
    The organisational hierarchy is listed as parent-child pairs, and is both ragged (unbalanced) and skip-level (noncovering). This would lend itself to a value-based hierarchy, but our client would rather we use ROLAP rather than MOLAP, i.e. avoid the use of an Analytical Workspace, which rules out the use of a value-based hierarchy.
    Is there a straightforward way to populate a level-based hierarchy using parent-child pair data, and if so how can it be done?
    Pointers to tutorials would be welcome, especially if they use Warehouse Builder.

    If you have an Oracle DB have a look on the CONNECT BY PRIOR functionality.
    regards
    John
    http://obiee101.blogspot.com

  • How to use Power Query to load data from a single source into multiple tables

    Hi all,
    I have a requirement to load my data into three different data models using Power Query. Is that possible?
    My source is a SharePoint survey list, with similar questions like:
    1) Course lecturer - John Doe
    1a) The course was useful (rate 1 to 5)
    1b) The lecturer displayed good knowledge of topic (rate 1 to 5)
    2) Course Lecturer - Mary Brown
    2a) The course was useful (rate 1 to 5)
    2b) The lecturer displayed good knowledge of topic (rate 1 to 5)
    I would like to split the data into separate data models (one for John Doe; another for Mary Brown), so that I can compare the different lecturers. Other than running separate surveys for each of them, I thought of using Power Query to transform the data.
    Is it possible?
    Thanks.
    Regards
    GM

    Yes, this is possible.
    Start with a single query that returns you the data for all lecturers.
    Right-click on the "all lecturers" query in the queries pane, and choose Reference, once for each lecturer. This will create a query for each lecturer.
    Open the query for each lecturer and filter the data so that only that lecturer's results are visible.
    Click "Close & Load To..." for each lecturer's query  to load the data into the data model. This will create a data model table for each lecturer.
    If your question is more about how to transform such a survey list into a table that can be easily filtered, please provide an example of how the list shows up in Power Query.
    Ehren

  • Query to get the data of all the columns in a table except any one column

    Can anyone please tell how to write a query to get the data of all the columns in a table except one particular column..
    For Example:
    Let us consider the EMP table.,
    From this table except the column comm all the remaining columns of the table should be listed
    For this we can write a query like this..
    Select empno, ename, job, mgr, sal, hiredate, deptno from emp;
    Just to avoid only one column, I mentioned all the remaining ( 7 ) columns of the table in the query..
    As the EMP table consists only 8 columns, it doesn't seem much difficult to mention all the columns in the query,
    but if a table have 100 columns in the table, then do we have to mention all the columns in the query..?
    Is there any other way of writing the query to get the required result..?
    Thanks..

    Your best best it to just list all the columns. Any other method will just cause more headaches and complicated code.
    If you really need to list all the columns for a table because you don't want to type them, just use something like...
    SQL> ed
    Wrote file afiedt.buf
      1  select trim(',' from sys_connect_by_path(column_name,',')) as columns
      2  from (select column_name, row_number() over (order by column_id) as column_id
      3        from user_tab_cols
      4        where column_name not in ('COMM')
      5        and   table_name = 'EMP'
      6       )
      7  where connect_by_isleaf = 1
      8  connect by column_id = prior column_id + 1
      9* start with column_id = 1
    SQL> /
    COLUMNS
    EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,DEPTNO
    SQL>

  • Not able to get the Qualification data from BAPI

    Hi all,
    I am using a BAPI (BAPI_JOBREQUIRE_GETLIST) to get the qualifiaction data for requirement profile. It's working fine earlier but I did not get the qualification data from this BAPI, although the data is there in DB against this requirement profile.
    Can someone suggest me why I am getting this issue. I have looked into SDN and in BAPI documentation and found as below:
    "You require authorization (structural authorization) to read the Requirements subprofile."
    I am having the same User ID as I had before (when I getting back the correct data), so I don't think it should be authorization issue.
    Can someone help me out in this issue please.
    Thanks,
    Sanket Sethi

    Hi Shiva,
    It does not going to these includes at all. Message comes out with successfully done. The BApi is calling RHPP_COMMON_QUALI_READ inside, but this will not return any data. But if will call any qualification object ID, this BAPI will come up with data.
    So the QP type LO profile will not come up with any kind of data, but if we pass the OTYPE as Q and pass any Qualification object ID then the data will be returned.
    Is there any relationship or some other thing is missing? Any idea.
    Thanks,
    Sanket Sethi

  • I'm getting a "No Data From Device" error for older video import

    I'm trying to create digital video archives of some older (Hi-8) tapes before they turn to dust.  I've got a Sony deck with iLink and have been using iMovie, which is time consuming but error free.  I want to use the "Create Camera Archives" feature in FCP X, but am not able to import any video. FCP recognizes the deck, lets me control it and displays video in the capture window.  But it does not capture anything - camera archives are empty and when I try to import the video I get a "No Data from Device" message over the import window, as the video is playing in the background.  I thought it might be an issue of import settings... but I can't find any to change.
    Any advice appreciated. Thanks.

    Make sure all your settings are correct for capture and playback. Also make sure that the settings on the deck are the same as well. I know I had an issue when my Sony FX1 HDV camera was set to DV, FCP gave a similar error message.

  • Using sql load insert multiple fields data into a single column in database

    Hi ,
    I have my log file in sun OS box something like this
    =======
    (07/29/2009 00:02:24.467) 367518 (07/29/2009 00:02:26.214) 949384011
    (07/29/2009 00:02:26.236) 3675 (07/29/2009 00:02:28.207) 949395117
    (07/29/2009 00:02:28.240) 337710 (07/29/2009 00:02:30.621) 949400864
    =============
    I am trying to insert the data into oracle data base as follows.
    =============================
    column1 : (07/29/2009 00:02:24.467)
    column2 : 367518
    column3 : (07/29/2009 00:02:26.214)
    column4 : 949384011
    ===========================
    Can anyone help me with the control file format?
    someone suggested me the code below.
    ==========
    LOAD DATA
    INFILE 'D:\work\load.txt'
    INTO TABLE sample
    (col1 POSITION(02:24) char,
    col2 POSITION(27:32) INTEGER EXTERNAL,
    col3 POSITION(35:57) CHAR,
    col4 POSITION(60:68) INTEGER EXTERNAL
    ===========
    but this works only for the fixed length data? Please help

    user11744904 wrote:
    Hi ,
    I have my log file in sun OS box something like this
    =======
    (07/29/2009 00:02:24.467) 367518 (07/29/2009 00:02:26.214) 949384011
    (07/29/2009 00:02:26.236) 3675 (07/29/2009 00:02:28.207) 949395117
    (07/29/2009 00:02:28.240) 337710 (07/29/2009 00:02:30.621) 949400864
    =============
    I am trying to insert the data into oracle data base as follows.
    =============================
    column1 : (07/29/2009 00:02:24.467)
    column2 : 367518
    column3 : (07/29/2009 00:02:26.214)
    column4 : 949384011
    ===========================
    Can anyone help me with the control file format?
    someone suggested me the code below.
    ==========
    LOAD DATA
    INFILE 'D:\work\load.txt'
    INTO TABLE sample
    (col1 POSITION(02:24) char,
    col2 POSITION(27:32) INTEGER EXTERNAL,
    col3 POSITION(35:57) CHAR,
    col4 POSITION(60:68) INTEGER EXTERNAL
    ===========
    but this works only for the fixed length data? Please helpIs the requirement to load all data in a single column or multiple columns? The thread subject and body are conflicting.

  • TS1474 I have a new PC - great.  But the old PC has now gone and taken the backup of my iPhone 4S with it.  How do I get all my data from my iPhone to a new copy of iTunes on the new PC?

    I have a new PC - great.  But my iTunes library has now gone with the old PC.  With a new iTunes library how do I get all my data from my iPhone to a new copy of iTunes on the new PC?

    It has always been very basic to always maintain a backup copy of your computer.
    Have you failed to do this?

  • I lost my iphone. How can I get my saved data from back up on my new laptop?

    Dear Friends,
    I did a mistake as when selling my iphone I did not get my saved data from my iphone back up. Now I have a new laptop and I want to get my backed up data.
    Is there any way I could get or as Apples traditional greed ... more money more money ...more .. more??????
    Please help if I can get back my at least contacts and video for free. I do not are for my music. My God it is so difficult to get going with Apple.

    stedman1 wrote:
    A warranty does not cover physical damage. Did you have AppleCare +?
    AppleCare+ doesn't cover loss or theft, only accidental damage.

  • Parent-Child hierarchy based on two-column key

    Hello
    Is it possible to create a parent-child hierarchy, if the primary key of the table consists of two columns?
    My table looks like:
    TRACE_ID | DIAG_ID | SUPER_DIAG_ID
    with TRACE_ID and DIAG_ID as PK.
    If I define only DIAG_ID as PK, I can add a logical dimension (PC-hierarchy) without problems.
    However when I also add TRACE_ID to my PK, I cannot select a member key in the new logical dimension window and therefore not create a logical dimension.
    Is this a limitation of OBIEE and I have to merge the two colums (which would be rather bad, as there are FK relations to DIAG_ID) or is there a solution?
    Regards
    Matthias

    Dear Gowtham  ,
    I am very well aware of the level based hierarchy available in BO .
    The issue that i have raised is all about the Parent Child Hierarchy which creates the recursive query.
    I.e Every Parent has a child and that child can be parent of some other . (See the original example for more illustration)

  • Variant must get the current date from the system.

    Hi All,
    I really appreciate your help on below please;
    I need to create a variant and schedule a report program once a day.
    But variant must get the current date from the system (sy-datum).
    The program should run for the values in the variant in schedule job run;
    Can I do this using SAP variants (for Report Program) and schedule the job.
    Many thanks
    Iver

    Standard functionality.
    http://help.sap.com/saphelp_nw70/helpdata/en/c0/98039be58611d194cc00a0c94260a5/frameset.htm
    Thomas

  • "Could not get the audio data from the file" error

    Hi
    I get a lot of "Could not get the audio data from the file" errors when opening a project. Sometimes they crash Premiere Pro CC 7.01 (Mac). But if not Premiere works as usual, with the audio.
    I tried to convert the audio files (coming from Audition) from 32 to 16 bit. It worked while opening a project once, but not the following times.
    Where can it come from ?
    Edit: I also get this error when importing audio: "Error: Premiere Pro version 7.0 is not compatible with the Premiere Pro Plug-in version 5.7.4". Maybe it is connected.

    Got it! It was the Smartsound plugin making trouble. Got rid of it and no more errors.

  • Is there any way to get specific app data from iCloud so that when you redoes load an app, you can restore its data?

    Is there any way to get specific app data from iCloud so that when you redoes load an app, you can restore its data?

    no.
    the backup is only for the purpose if you need to wipe the device.

  • How i cen get back deleted data from the bin?

    how i cen get back deleted data from the bin?

    Not once you have put the data in the trash and pressed the button to delete it.
    There may be some hope if you can understand what I am telling you in my first post to you.
    Time machine is too complex to explain in this kind of post but I am giving you five links below which should explain quite a lot.   There are no formal instruction manuals for Time Machine.
    Time Machine Tutorial
    Time Machine 101
    How to back up and restore your files           This in particular
    Time Machine Features
    Apple - Support - Mac OSX v10.5 Leopard Time Machine

  • How to calculate the total of absences? How to collect data from a specific line of a table?

    Hi,
    Again, I made a nice coloured picture from a screen capture which summarise the improvements that I would like to make in my form,
    Situation:
    For an educational purpose, I made this form   to simplify the way of recording the data and also to develope the independence of the students.
    ( I am doing this on a voluntary basis, working extra hours on my free time but I don't really mind because I am learning a lot of things in the same time)
    After being tested by the teacher, the student has to record the short date, the lines memorised, his grade, number of mistakes, and his attendance.
    I created everything in Word, then converted the file in PDF, then I created all the different fields with Adobe acrobat.
    There is in total 4 sheets, there are all similar except the first one in which there is a box with: date started, date finished, total time spent, absences.
    Below this box there is a table with 16 lines from (A to P) and 7 columns (Days, Date, From.. to.. , Grade, No. lines memorised, No. Errors, Attendance) ( so this table is present on all the sheets)
    Due to the fact that some students need more time than others, and also beacause some text need more time, I estimated a need of 4 sheets at the very most.
    I would like to make the following amelioration and automate the inputting of some of the data because I know that some of the students will certainly forget, so to avoid this scenario I am trying to make this form the easiest possible.
    screen capture of the form:
    screen capture of the form editing, you can see the names of the different fields:
    here is the form (only the first page) : http://cjoint.com/12fe/BBotMMgfYIy_memorisation_sheet_sample.pdf
    In  yellow 00000:
    At present, the students has to input the total of absences manually, is there a way ( script) to automate this by initialising the field next to "Absences" at  " 0 day"   and then everytime that Absent is selected from the COMBO BOX, it add 1 and it is displayed like this:  " 1 day" then " 2 days"  then " 3 days" etc … (so from what I read I have to initialise a counter a the beginning and then for (i...   ) count= count++; something like this...
    Furthermore, I need a solution to overcome the possibility that a second sheet may be needed for the same student; therefore I would need the data from the "attendance column" from the second sheet ( and perhaps the 3rd and 4th aswell) to be added on the "absences field" in the first sheet
    My idea: everytime that the short date is inputted in the first line (next to A) in the "Date" column of one of the 4 sheets then we check the 16 Combo box of the attendance column in this sheet instead to check 16*4=64 fields fot the 4 sheets in one go?
    but I don't know at all how to write it in Javascript. Or perhaps there is a way more easier than that?
    Shall I allocate a value for Absent on the “ export value”?
    In purple
    At present I wrote a simple script which matches the number of lines to the poem selected (Eg.  if I select the poem V.Hugo,  the number "36" will appear next to Number of lines).
    Again I would like the make the life of the students very easy so I would like a script which detects this number “36” on the "From .. to …" column,  as soon it is detected (on the first sheet or 2nd or 3rd or 4th)  check from the same line if "A / Pass" or "B / Pass" have been selected in the "Grade" column ,if yes the short date inputted on this line will be written on the field next to "Date finished" .
    this is a simple example with 36 lines only but somethimes, the students may have to memorise 80 lines and more, this is the reason for having 4 sheets in total.
    So basically I would like to automate the field next to" Date finished:" with a script that collect the short date from the day in which the student has finished his memorisation with "A / Pass" or "B / Pass"
    As for the "Total time spent" George Johnson helped me with a script that calculate the difference betwen date started and date finished (thank you)
    I am sollicting your help, because after trying for hours I was really confused with the different if/else needed. And in top of that, it’s my first experience with Javascript.
    I anticipate your assistance, thanking you in advance.

    I found this for counting the absences, its give you the total that's perfect, but is there a better methode which avoid me to write all the fields name, more simple????
    ( I found the idea here : Re: Total number added automatically  )
    // custom calculation script for field "Total #"
    function CountFields(aFields) {
    var nFields = 0;
    for(i = 0; i < aFields.length; i++) {
    try {
    // count null values, export value of Absence is 0;
    if(this.getField(aFields[i]).value == "0") nFields++;
    } catch(e) {
    if(e['message'] == "this.getField(aFields[i]) has no properties") app.alert("unknown field name: " + aFields[i]);
    else app.alert(e.toString());
    } // end catch
    } // end for aFields
    return nFields;
    // create array of field names to count
    var aNames = new Array("Sheet1AttendanceA","Sheet1AttendanceB","Sheet1AttendanceC","Sheet1AttendanceD","Sh eet1AttendanceE","Sheet1AttendanceF",
    "Sheet1AttendanceG","Sheet1AttendanceH","Sheet1AttendanceI","Sheet1AttendanceJ","Sheet1Att endanceK","Sheet1AttendanceL",
    "Sheet1AttendanceM","Sheet1AttendanceN","Sheet1AttendanceO","Sheet1AttendanceP" );
    // count the non-null fields;
    event.value = CountFields(aNames);
    As for the 2nd question, I've tried to do something similar to the previous script, but of course it doesn't work, but I am quite sure that the idea is similar:
    I don't know also how to add the other condition: the student should get A / Pass or B / Pass in order to consider he has finished??? and also how to check these condition from page 2, 3 and 4 and collect the date
    function Datefinished(bFields) {
    d2.value = nFields[i].value;
    for(i = 0; i < aFields.length; i++) {
    try {
    if(this.getField(aFields[i]).value == this.getField("NumberLines").value) d2.value = nFields[i].value;
    } catch(e) {
    if(e['message'] == "this.getField(aFields[i]) has no properties") app.alert("unknown field name: " + aFields[i]);
    else app.alert(e.toString());
    } // end catch
    } // end for aFields
    return nFields;
    // create array of field names to check
    var aNames = new Array("Texte00","Texte54","Texte56","Texte58","Texte60","Texte62","Texte64","Texte66","Te xte68","Texte70","Texte72","Texte74","Texte76","Texte78","Texte80","Texte82");
    var bNames = new Array("d1","d3","d4","d5","d6","d7","d8","d9","d10","d11","d12","d13","d14 ","d15","d16","d17");   // d1 is included because in some cases a student can finish in 1 day (short text);

Maybe you are looking for

  • Encrypt files in time capsule

    how to encrypt files that are backed up in airport time capsule?

  • Pictures not loading up in safari/firefox

    hi im using facebook and many of the applications on it for the past two weeks the pictures which usually come up, initially come up as a box to show the picture is loading up, then the box just disappers with no picture at all. i try the exact same

  • Adding soap header in MX6.1

    I have a code working on MX7, it first adds soap header(username and password) then gets the response, but similar code didn't work on MX6.1. Please help. MX7 code: <cfscript> ru = XmlNew(); ru.AuthenticationHeader = XmlElemNew(ru, " http://www.mytes

  • OS X Mavericks doesn't read my usb, sd and external hard drive

    Hi all, I am using Macbook pro (Mid 2010) and recently upgraded to OSX 10.9.3. Since switching to Mavericks, I have problems with using USB, SD Card and External hard drive (Freecom Classic II). The outcome is random. Sometimes, I am able to use it f

  • How can I stop Mail 5.2 changing my default font size in my signature in outgoing mail

    I have my default font size for messages and signature in messages both set as Century Gothic 10. When I send an email the message and signature font both appear correct in my saved "sent" email. However the receiving computers receive my email with