Generating Parent Number using Level and Display Number

I am facing problem in generating parent number using level and dispaly number.
Here is the table structure
CREATE TABLE test(
DISPLAY_NUMBER       NUMBER,
LEVEL_NUM           NUMBER,
COMPONENT   VARCHAR2(10))
INSERT INTO test VALUES (1,1,'A');
INSERT INTO test VALUES (2,2,'B');
INSERT INTO test VALUES (3,3,'C');
INSERT INTO test VALUES (4,4,'D');
INSERT INTO test VALUES (5,3,'E');
INSERT INTO test VALUES (6,3,'F');
INSERT INTO test VALUES (7,2,'G');
INSERT INTO test VALUES (8,3,'H');Here is the output table structure and required output data format
CREATE TABLE test1(
DISPLAY_NUMBER       NUMBER,
LEVEL_NUM           NUMBER,
COMPONENT   VARCHAR2(10),
PARENT VARCHAR2(10))
INSERT INTO test1 VALUES (1,1,'A',NULL);
INSERT INTO test1 VALUES (2,2,'B','A');
INSERT INTO test1 VALUES (3,3,'C','B');
INSERT INTO test1 VALUES (4,4,'D','C');
INSERT INTO test1 VALUES (5,3,'E','B');
INSERT INTO test1 VALUES (6,3,'F','B');
INSERT INTO test1 VALUES (7,2,'G','A');
INSERT INTO test1 VALUES (8,3,'H','B');Oracle database version : Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
Thanks in advance.
Regards,
Laxman

>
I am facing problem in generating parent number using level and dispaly number.
>
Thanks for posting the table DDL and data. I called the tables testa and testb.
insert into testb
select a.*, (select component from testa b where b.level_num + 1
  = a.level_num and rownum = 1) parent
from testa a
select * from testb
DISPLAY_NUMBER,LEVEL_NUM,COMPONENT,PARENT
1,1,A,
2,2,B,A
3,3,C,B
4,4,D,C
5,3,E,B
6,3,F,B
7,2,G,A
8,3,H,B

Similar Messages

  • Grab Frame Number, add 6 and display in dynamic textbox

    Hey,
    I have a gallery that needs numbered images. To do this I
    need to grab the current frame number of a parent movie, add 6 and
    display in a dynamic textbox. Sounds simple!
    The frame number I need to grab is in:
    _root.gallery
    The dynamic textbox has the var name 'displayNumber' and is
    in:
    _root.gallery.controlbox
    I need this to refresh every time the frame number changes in
    the _root.gallery clip. This is a fairly urgent project so swift
    help is obviously appreciated!
    Thank you in advance

    your code will work if all you state is valid and there's no
    other _root.gallery.onEnterFrame overwriting the one you
    posted.

  • HT4061 Hello, I was wondering if you could convert the IMEI # into the serial number using letters and digits?

    Hello, I was wondering if you could convert the IMEI # into the serial number using letters and digits?

    No the imei from what I understand is a randomly given number. to get serial number you must have it. you can try supportprofile.apple.com and login.

  • I am using IFrame and displayed Html page

    Hi Friends
                        I am using IFrame and displayed Html page in flex4
                        In this page open to Firefox But not IE please help me.
                          Thanks
                           V.ChandraSekhar

    You have deleted your page, but you have not deleted your page?
    Which is it?
    If you never saved it it is gone. If you saved it in Lion (OSX 10.7) with Pages 09 v4.1, there should be versions available when you mouse overv the document name at the top of the window.
    Peter

  • How I get random number between 1 and int number ?

    how can I get random number between 1 and int number
    like between 1 and 10 etc.
    10x

    Use the nextFloat() method of the Random class, this returns a random number between 0.0 and 1.0. To get and integer range from that multiply the return value of that method call by the integer range you need (in this case 10), and add the starting number you want returned in the range (1 in this case). The code below works for numbers 1-10.
    Random r = new Random();
    int x = (int)(r.nextFloat()*10) +1;

  • Stock Mismatch at Plant level and Serial Number Collection

    Hi,
    I'm working on with the material stocks in my application. For the serialised material (MATNR = 50004050), I'm gettting the plant level stock as 20 and the corresponding serial numbers collection for the same material is 27 which is wrong. Since the plant level stock and the serial number collection should be one and the same
    I'm using MARA, MARC table for getting the plant level stock and EQUI and EQBS table to get the serial number collection. If I increase the stock using the transaction 'MB1C' and movement type '561', the serial numbers which I'm giving for the serialised material is coming in the serial number collection but the plant level stock still in the previous value itself. If I raise the stock for the serialised material, the plant level stock also should get updated.
    Please let me know, how can I get the stock equal in both plant and serial number collection.
    Thanks in Advance,
    Mohan.

    This could happen, if the status of serial number is wrongly updated to ESTO. From where are you taking serial numbers?Physically what is right the qty showing plant stock or the qty showing serial number? May be you go and check the history of the serial number to see if it is really available in stock.
    Also it can be serial number is optional so though the stock is reduced but serial number is not captured while issuing so the stock at plant level is less but serial number is more,
    If this is the case, reconciallation directly from tables will be difficult.
    Regards
    Sangeeta
    Edited by: Sangeeta Khurana on May 4, 2011 12:34 AM

  • Need help to count number of rows and display in file

    Hello,
    my scenario is IDOC to File......i am using XSLT mapping and using FCC parameters to convert the flat file.
    now new requirement is i need to count number of rows and add count value last of the file.
    Please let me know how to do it,
    thanks in advance for your help.
    Regards,
    Chinna

    thanks again, one more Q.
    in XSLT mapping i have written for loop for complete structure.
    example : <Details>
                         <node1>
                         <node2>
                   </details>
    in XSLT mapping
                         <xsl:for-each select="ZMATMAS_01/IDOC/E1MARAM">
         <Details>
         </Details>
         </xsl:for-each>
    if i add the field at target side....then i will come under details node and it will be repeated.
    how to declare in XSLT mapping.

  • Help with removing a variable number using "find and replace"

    Hey, I have to remove a variable number from a large number of documents.
    How would I do this using "find and replace"
    <text><![CDATA[Coloured 250]]></text>
    250 is an example of the variable number that I will need to remove so it looks like this:
    <text><![CDATA[Coloured]]></text>
    Note: the text "coloured" is subject to change also.
    Thanks

    That's a possibilitly I'll explore.  Thanks for the alternate perspective!
    (5 minutes later)
    Oh well, it was a good thought.
    Unfortunately each line of raw original text may contain from 1 to 4 lines of final text.  In other words there is no consistency in the number of backslashes (hard returns) in each line of original text, and thus, when backslashes are converted to commas, no consistency in the number of data elements in each data set. 
    Sadly PS variables will not handle finding a source text line that does not have data for 4 variables.  So I either have to go back and add enough commas on each short line to make four individual data elements for each data set... or I simply deal with the hard returns within Photoshop.
    I think I've reached the limit of automation on this process.

  • Return the end of week date using month and week number

    Hi all,
    I am trying to find the date for end of the week using given month (201401, 201402...i.e, 2014 is year and 01,02 are months) and week number (01,02,03...) for the year. For example if my month is 201402 and week_number is 06 then it return the week_date
    as 2014-02-08. Can you please help me in writing a sql statement for this scenario.
    Thanks in advance,
    Nikhil

    Current month is irrelevant
    with dt as (
       select dateadd(day, (6-1)*7, '2014-01-01') as xwk
    select dateadd(day, 7-datepart(weekday, dt.xwk), xwk)
    from dt;
    Change the "6" in the with statement to the week of interest and 2014 to the year of interest...

  • Using methods to  display number

    I have to write a program that can display a phone # in big form down the screen
    11 2222 3333
    11 22 3
    11 22 333
    11 22 3
    11 22222 3333
    but i have no clue how to change a number given to the computer into the big form above could anyone help me on this?

    You store the "big" representation of each number.
    Say each big number consists of 5 lines (as in yor
    eaxmple). Then you first print the first line of each
    number on the same line, then the second etcetera.But if you're just printing to a stream, this wouldn't work. You can only print 1 char at a time (text cursor is down a row when it ends)

  • Change BarCode from Trip number to Pernr and Trip Number

    Hi Gurus,
    My client wants the Expense report bar code to be changed from Trip number to Personnel number and Trip number. The technical team has been able to merge the two entries, but the report displays only 10 characters. They are unable to extend the field length to 18 characters. Can this be resolved through configuration?
    Thanks,
    Eziudo

        Daet, the security of your account is our first priority! You can call us from your device by dialing *611 or 800-922-0204. Additionally, click http://vz.to/1Edfg0z to contact us online.
    LasinaH_VZW
    Follow us on Twitter @VZWSupport

  • Creating Bar Charts using Java and Display in jsp

    Hi..Is it possible to create a servlet that processes data from database and display the values as Bar Charts in jsp pages. If its possible, is there any examples on how to achieve that?

    I don't get it. You already know what needs to be done to solve your problem, the only thing you are missing is the HOW. That's the easy part, if only you break down what you have to know:
    1) how do I show an image on a website (this is a basic HTML question actually, not actually related to servlets/JSPs directly)
    2) how do I fetch the path from a database (JDBC question) so that I can use this path to link to my image on disc
    So what is preventing you from figuring out how to do these two simple tasks? Some clever google searches should give you all the information you need in no time.
    by the way: are you sure that you need to store these paths in the database? Is this part of some file upload component?

  • How do I upload an image using as3 and display it without a server?

    Is it possible to upload an image using as3 and flash player 9 and then display it in a movie clip without server side assistance?
    thanks,
    JB

    Hi,
    Check out the links..
    I hope it will helps u.
    http://labs.findsubstance.com/2008/04/03/as3-upload-encode-images/
    http://flexscript.wordpress.com/2009/01/12/uploading-an-image-into-flash-without-server-si de-script-using-flash-player-10/
    Saransoft

  • How to generate the reports in BI and display in EP ?

    Hi All
       I am new to BI but i am working on EP
       Can any one help me how to generate the reports in BI and should be displayed
       in EP frontend?  So what and all settings and installations i need to do ?
       Any documents on this will be really helpful to me..........
    Adv...thanks and regards
    Kops

    Hi kops,
    Check the links below.What you need is there..
    How can i place a query developed in BEX to portal
    http://help.sap.com/saphelp_nw04s/helpdata/en/43/92dceb49fd25e5e10000000a1553f7/frameset.htm
    http://help.sap.com/saphelp_nw04s/helpdata/en/33/39fa40ee14f26fe10000000a1550b0/frameset.htm

  • Can load image from file using LabVIEW and display on IMAQ graph?

    I dont have IMAQ Vision for LabVIEW on my computer. Is it possible to load image file and display on an IMAQ graph?
    Thanks!

    Hey werwr,
    In response to: "I dont have IMAQ Vision for LabVIEW on my computer. Is it possible to load image file and display on an IMAQ graph?"
    As of right now, in order to read an image from file, you actually do need the IMAQ Vision software. The IMAQ driver without the Vision VI's will allow you to collect images from a framegrabber, and it will allow you to save those images to file. But the function that allows you to read an image from file does require the Vision VI's. Once you have the VI to read images from a file, you will be able to display the image on an IMAQ "Graph" or otherwise known as an Image Display.
    I hope this helps. Please let me know if you have any further questions.
    Thanks,
    DJ
    Applications Engineer
    National Instruments

Maybe you are looking for