How to write query to get the following o/p

Hi i've the following data and
create table hirarchical(prnt_id number,child_id number)
insert into hirarchical values(1,2)
insert into hirarchical values(1,3)
insert into hirarchical values(1,4)
insert into hirarchical values(2,5)
insert into hirarchical values(2,6)
insert into hirarchical values(2,7)
insert into hirarchical values(3,8)and
If i give in where condition prnt_id=1 then
the o/p should be 7 instead of 1 as it's having all connected childs...
thanks in advance

user10502250 wrote:
If my reply is correct or helpful please mark it so.Begging for points is unprofessional and considered poor netiquette. It also makes a mockery of the already poor points system, by putting pressure on the original poster to award points for answers that may or may not be the most helpful or correct. If your answer is correct or helpful and meets the needs of the original poster then it is entirely up to them to award points as they see fit when they feel they have had sufficient answers or responses. Most of the people on the forum who have gained a lot of points have done so through providing good answers and without needing to ask for them. Please avoid such begging in future.

Similar Messages

  • Query to get the following criteria

    Hi all
    I've the following tables
    rec ,pay ,cact ,isumand the relation between them is
    isum.invid=rec.INVID_ARREC
    isum.invid=pay.invid_arpay
    cact.arpayid_cb=pay.arpayid
    cact.arrecid_cb=rec.arrecidi need to get the o/p of BAL , SUM(TAMT) , SUM(VAL)
    which will have the same amounts.
    How can i get that
    i tried the following but getting the duplicate records
    plz help me in completing this query
    SELECT bal, tamt, val
      FROM rec ,
           isum ,
           (SELECT   SUM (tamt) tamt
                FROM rec, cact, isum i
               WHERE
                  i.invid = invid_arrec
                 AND arrecid_cb = arrecid
                 GROUP BY invid_arrec),
           (SELECT   SUM (val) val
                FROM pay, isum i
               WHERE i.invid = invid_arpay            
            GROUP BY invid_arpay)
    WHERE invid = invid_arrecplz let me know if more info is required
    plz help..
    Edited by: smile on Oct 22, 2010 1:38 AM
    Edited by: smile on Oct 22, 2010 1:39 AM

    we don't have your tables, we don't have your data, we don't have your database.
    you want help, you provide all that is necessary to help you.
    CREATE TABLE; INSERT INTO...
    from what I can tell now, just join the tables and use the SUM function...

  • How to write test procedures of the following code, need someones help

    ITS VERY URGENT.....PLEASE SEND ME THE REPLY ON MY EMAIL ID [email protected]
    // Account.java - Data class for account files
    // MODULE INDEX
    // NAME CONTENTS
    // Account Constructor
    // Account Constructor
    // getAccountNo Get account identifier
    // getAccountType Get account type
    // getCustNo Get customer identifier
    // getBalance Get balance
    // getCurCode Get currency code
    // setAccountNo Set account identifier
    // setAccountType Set account type
    // setCustNo Set customer identifier
    // setBalance Set balance
    // setCurCode Set currency code
    // MAINTENANCE HISTORY
    // DATE PROGRAMMER AND DETAILS
    // 6-5-08 TLT Original
    // IMPORTATIONS
    import java.util.*;
    import java.lang.*;
    // CLASS DECLARATIONS
    public class Account
    // INSTANCE DATA
    private String accountNo; //Account identifier
    private String accountType; //Account type
    private String custNo; //Customer identifier
    private double balance; //Balance
    private String curCode; //Currency code
    // CLASS CONSTRUCTOR
    Account (
    String accountNo) //Account idenfier
         this.accountNo = accountNo;
    Account (
         String accountNo, //Account identifier
         String accountType, //Account type
         String custNo, //Customer identifier
         double balance, //Balance
         String curCode) //Currency code
    this.accountNo = accountNo;
    this.accountType = accountType;
    this.custNo = custNo;
    this.balance = balance;
    this.curCode = curCode;
    // Get account identifier
    String getAccountNo () {
    return accountNo;
    // Get account type
    String getAccountType () {
    return accountType;
    // Get customer identifier
    String getCustNo () {
    return custNo;
    // Get balance
    double getBalance () {
    return balance;
    // Get currency code
    String getCurCode () {
    return curCode;
    // Set account identifier
    void setAccountNo (
    String accountNo)
    this.accountNo = accountNo;
    // Set account type
    void setAccountType (
    String accountType)
    this.accountType = accountType;
    // Set customer identifier
    void setCustNo (String custNo) {
    this.custNo = custNo;
    // Set balance
    void setBalance (double balance) {
    this.balance = balance;
    // Set currency code
    void setCurCode (String curCode) {
    this.curCode = curCode;
    }

    123shweta wrote:
    ITS VERY URGENT.....W00t? Well if its soo urgent then perhaps you should learn from this and do some planning ahead in the future so you dont find ur self in these urgent needs.
    PLEASE SEND ME THE REPLY ON MY EMAIL ID [email protected]
    Wat tha.., do you expect someone to just magically solve your problem for ya just like that? with an half asked question even.
    Last but not least.. Why would you even need an test for an getters and setter class?

  • Help in query to get the max(date)

    Hi I have query like below and based on the query I get the following results,
    SELECT a.UsageId,a.product,ProductDate
    FROM dbo.table1 a
    JOIN dbo.table2 b ON a.SID= b.SID
    JOIN dbo.table3 c ON b.CID = c.CID
    UsageId        Product          UsageDate
    1 Yellow 2014-01-01
    2 Yellow 2014-01-02
    3 Yellow 2014-01-03
    4 Yellow 2014-01-04
    5 Red 2014-01-01
    6 Red 2014-01-02
    7 Blue 2014-01-03
    8 Blue
    2014-01-04
    Now I want to add a new column which gives me the Max(UsageDate) of the column Prdouct last Usage.
    UsageId        Product          UsageDate          Max(UsageDate)
    1 Yellow
    2014-01-01          2014-01-04
    2 Yellow
    2014-01-02    2014-01-04
    3 Yellow
    2014-01-03          2014-01-04
    4 Yellow
    2014-01-04          2014-01-04
    5 Red 2014-01-01          2014-01-02 
    6 Red 2014-01-02          2014-01-02
    7 Blue
    2014-01-03          2014-01-04
    8 Blue
    2014-01-04          2014-01-04

    Simply use:
    SELECT a.UsageId,a.product,ProductDate, MAX(ProductDate) OVER (PARTITION BY a.ProductID) as [Latest Product Usage Date]
    FROM dbo.table1 a
    JOIN dbo.table2 b ON a.SID= b.SID
    JOIN dbo.table3 c ON b.CID = c.CID
    For every expert, there is an equal and opposite expert. - Becker's Law
    My blog
    My TechNet articles

  • No matter how I try to finalize my imovie , I get the following message:  "The project could not be prepared for publishing because an error occurred. (Error code = -49))"

    No matter how I try to finalize an imovie I get the following message:
    "The project could not be prepared for publishing because an error occurred. (Error code = -49)"

    Hi
    Error -49 opWrErr  File already open with write permission
    Trash the preference files while application is NOT Running.
    Easiest way to find out if this is the problem is by:
    • Create a new User-Account
    • Log out of Your old one and into this
    • Re-try iMovie
    If it now works OK - then 99.9% the problem is iMovie pref. file that needs to be trashed.
    from Karsten Schlüter
    Some users notice on exporting larger projects from within iMovie that this operation is aborted with an 'error -49'
    This issue occurs only on MacOs machines using 10.7x
    try switching-off the Local Mobile Backup
    in Terminal copy/paste
    sudo tmutil disablelocal
    Re-launch Mac
    Yours Bengt W

  • How can I get the following result?

    Hi, I have table test:
    create table test(oper_date date, income number, expense number), there are several records in this table:
    20060101 100 10
    20060105 200 15
    20060106 150 12
    20060109 30 8
    I want to get the following result:
    20060101 100 10
    20060102 0 0
    20060103 0 0
    20060104 0 0
    20060105 200 15
    20060106 150 12
    20060107 0 0
    20060108 0 0
    20060109 30 8
    How should I write the sql?
    Please give some help!
    Thank you all!

    I used the script below:
    CREATE TABLE mhe_foo( oper_date DATE 
                        , income    NUMBER
                        , expense   NUMBER
    INSERT INTO mhe_foo VALUES(TO_DATE('20060101','YYYYMMDD'), 100, 10)
    INSERT INTO mhe_foo VALUES(TO_DATE('20060105','YYYYMMDD'), 200, 15)
    INSERT INTO mhe_foo VALUES(TO_DATE('20060106','YYYYMMDD'), 150, 12)
    INSERT INTO mhe_foo VALUES(TO_DATE('20060109','YYYYMMDD'),  30,  8)
    SELECT v.oper_date
         , NVL(m.income,0)  AS income
         , NVL(m.expense,0) AS expense
    FROM   ( SELECT  mindt + level - 1 AS oper_date
             FROM    ( SELECT MIN(oper_date) mindt
                            , MAX(oper_date) maxdt
                       FROM   mhe_foo
             CONNECT BY mindt + LEVEL -1 <= maxdt
           ) v
         , mhe_foo m
    WHERE  v.oper_date = m.oper_date(+)
    ORDER BY v.oper_date
    DROP TABLE mhe_foo
    /I saved it as C:\T1\myscript.sql and ran it:
    SQL> @C:\t1\myscript
    Table created.
    1 row created.
    1 row created.
    1 row created.
    1 row created.
    OPER_DATE     INCOME    EXPENSE
    01-JAN-06        100         10
    02-JAN-06          0          0
    03-JAN-06          0          0
    04-JAN-06          0          0
    05-JAN-06        200         15
    06-JAN-06        150         12
    07-JAN-06          0          0
    08-JAN-06          0          0
    09-JAN-06         30          8
    9 rows selected.
    Table dropped.
    SQL>MHE
    Message was edited by:
    maaher

  • Hi. I get the following message when trying to update or install an application: "impossible to connect to iTunes store". Does anyone know how to fix this? Thanks!

    Hi. I get the following message when trying to update or install an application: "impossible to connect to iTunes store". Does anyone know how to fix this? Thanks!

    Try updating your iTunes using an iTunesSetup.exe (or iTunes64Setup.exe) installer file downloaded from the Apple website:
    http://www.apple.com/itunes/download/

  • How to Find out the from which table we can get the following fields?

    The following fields are from invoice data
    How to  know or from which table we get the following fields:
    Header Details:
    Manifest:, Finance Control #:, Alternate SID:, Carrier:, Container/Trailer #:, Hazmat Code:, Harmonizing Code, Freight Forwarder, Fiscal Rep., Ship From,  Notify Party
    Item Details:
    VAT/Tax Rate %, VAT/Tax Amount, Measurements, Net Weight, Gross Weight
    thanks

    Dear Krishnama
    Place your mouse on the required fields and press F1.  A box with header Performance Assistant will appear in front of you where you select "Technical information" (icon like hammer and spanner). 
    You can now see what table it is.
    thanks
    G. Lakshmipathi

  • I am trying to remove itunes and I am getting the following error,"the feature you are trying to use is on a network resource that is unavailable" How do I go about uninstalling?

    I am trying to update to iTunes 10.5.  I keep getting the following error, " The feature you are trying to use is on a network resource that is unavailable"  How do I proceed to uninstall iTunes?

    Many thanks.
    Unfortunately, this sort of trouble has gotten more complicated to deal with ever since Microsoft pulled the Windows Installer CleanUp utility from their Download Center. First we have to find a copy of the utility.
    Let's try Googling. (Best not to use Bing, I think.) Look for a working download site for at least version 3.0 of the Windows Installer CleanUp utility. (The results from mydigitallife and Major Geeks are worth checking.)
    After downloading the utility installer file (msicuu2.exe), scan the file for malware, just in case. (I use the free version of Malwarebytes AntiMalware to do single-file scans for that.)
    If the file is clean, to install the utility, doubleclick the msicuu2.exe file you've downloaded.
    Now run the utility ("Start > All Programs > Windows Install Clean Up"). In the list of programs that appears in CleanUp, select any iTunes entries and click "Remove".
    Quit out of CleanUp. Restart the PC, and try another iTunes install. Does it go through properly this time?

  • HT1926 when trying to setup itunes on my pc i get the following message: there is a problem with this Windows installer package. A program required for this install to complete could not be run. How could I solve this problem?

    when trying to setup itunes on my pc i get the following message: there is a problem with this Windows installer package. A program required for this install to complete could not be run. How could I solve this problem?

    Repair your Apple software update.
    Go to START/ALL PROGRAMS/Apple Software Update. If it offers you a newer version of Apple Software Update, do it but Deselect any other software offered at the same time. Once done, try another iTunes install
    If you don't find ASU, go to Control Panel:
    START/CONTROL PANEL/Programs n Features/highlight ASU and click REPAIR,

  • After installing iTunes 10.5 update i get the following message when trying to play any song in my Library "The song could not be used because the original file could not be found. Would you like to locate it?"  how do i fix this??

    I have an iPod Classic and work on Windows 7.
    i recently installed iTunes 10.5 update and since then i cannot play any of the songs in the Library - i get the following message
    "The song could not be used because the original file could not be found.  Would you like to locate it?"
    what happened to all my songs (almost 2000) How can i get them back into my music library?
    Please help - i do not want to spend another week downloading all my cd's onto my computer !!!!!

    Try my script FindTracks. Select a few of the missing files to start with then run the script. Choose No at the first prompt so that you can check how it works track by track, then confirm or edit the location of the media folder where your files are. Once you are happy with how it behaves let it process larger numbers of tracks automatically.
    tt2

  • When I click on a link in an email I get the following message at the top of the screen: "Firefox prevented this page from automatically redirecting to another page...[Allow]. How can I stop this?

    When I click on a link in an email using gmail in the Mozilla brower, I get the following message at the top of the screen:
    "Firefox prevented this page from automatically redirecting to another page...[Allow].
    How can I stop this?

    # Press Alt+T
    # Select Options
    # Select Advanced Panel
    # Select General Tab
    # You will see option "Warn me when websites try to redirect or reload page"
    # Uncheck it as given in the screenshot.
    <img src=http://dl.dropbox.com/u/7456129/Firefox/advancedgeneraltab.jpg width=600px height=600px>
    ''<hr>Note: If anyone's reply has solved your problem, then please mark that reply as "Solved It" to the right of that reply after logging in your account. It will help us to concentrate on new questions.''

  • Getting the following message on Final Cut Express "audio only capture selected video preview disabled" how can I get the video capture back?

    I'm getting the following message on screen when attempting to capture video  "audio only capture selected, video preview disabled."  How can I get the view preview back?

    FCE doesn't allow for audio only capture, it's in a twist somewhere.
    Try trashing the FCE preferences.
    Al

  • When I try to sync my ipad using itunes I get the following message. This iPad cannot be synced. You do not have enough access privileges for this operation. Any ideas how this can be resolved?

    When I try to sync my ipad using itunes I get the following message. This iPad cannot be synced. You do not have enough access privileges for this operation. Any ideas how this can be resolved?

    See if the user tip helps: https://discussions.apple.com/docs/DOC-6562

  • HT1766 At the end of a synch I am getting the following error message "iTunes could not back up the iPod because the backup could not be saved on the computer".  Any ideas on how to resolve?

    At the end of a synch I am getting the following error message "iTunes could not back up the iPod because the backup could not be saved on the computer".  Any ideas on how to resolve?

    See:
    iOS: Troubleshooting backup issues in iTunes
    Try going to iTunes>Preferences>Devices and delete the existing backup so iTunes creates an entire new one vice changing the existing one.

Maybe you are looking for

  • Currency Translation in BO 4.0 Analysis Edition Office 1.1

    Hi, We are using Analysis Edition Office 1.1 for reporting and SAP BW system as source. After I create the report, I would like to change the currency for USD instead of report currency which is CAD. We have an option of Currency Translation availabl

  • STB will not activate

    I find this satisfaction hard to believe. Now don't get me wrong I have Fios because when the product is working and you don't have to deal with "tech" support or incompetant people on the phone it's brilliant. Fastest, most reliable internet I can g

  • Looking for a sound editing expert

    I have a message from 1995 that was recorded on my then tape answering machine. Unfortunately I did not dub the tape to my then LC III using a audio cable, and the original tape is gone. Before the message was destroyed I recorded it to my computer u

  • Strange security sandbox error

    Hi, I have a strange error when debugging my projects on localhost. Here what i get (sorry it's french, I tried to translate it below) : Erreur :Impossible de charger un fichier de régulation à partir de xmlsocket://127.0.0.1:5800 Erreur :La demande

  • Transfer workspace from CS6 to CC

    Where is the workspace file? I want to transfer my workspace from CS to CC. Dreamweaver was no problem.