Question about query hirarchical

Hi gurus!

I have a problem with a query hirarchical. I want is possible to query the information on the table a and b table of hierarchically.

Table one
< pre >
e_id, e_name e_num
1 ABC 100
2 200 DEF
< / pre >
Table b
< pre >
d_id, d_name e_id d_num
1 300 ABC 1
2 400 DEF 1
3 500 GHI 2
4 600 JKL 2
< / pre >

The lines should be displayed like this:
< pre >
e_id, e_name d_id, d_name d_num e_num
1 ABC 100
1 300 ABC
DEF 2 400
2 200 DEF
3 500 GHI
4 600 JKL
< / pre >

Please tell me if this is possible.

I'm waiting for your answers.

Yours sincerely


Florian W.

Florian,

This isn't exactly a hierarchical query as far as I can see, but you can generate the additional lines using a rollup:

SQL> create table a (e_id, e_num, e_name)
  2  as
  3  select 1, 100, 'ABC' from dual union all
  4  select 2, 200, 'DEF' from dual
  5  /

Tabel is aangemaakt.

SQL> create table b (d_id, d_num, d_name, e_id)
  2  as
  3  select 1, 300, 'ABC', 1 from dual union all
  4  select 2, 400, 'DEF', 1 from dual union all
  5  select 3, 500, 'GHI', 2 from dual union all
  6  select 4, 600, 'JKL', 2 from dual
  7  /

Tabel is aangemaakt.

SQL> select case lag(max(a.e_id)) over (partition by a.e_id order by b.d_id nulls first) when a.e_id then null else max(a.e_id) end e_id
  2       , case lag(max(a.e_num)) over (partition by a.e_id order by b.d_id nulls first) when a.e_num then null else max(a.e_num) end e_num
  3       , case lag(max(a.e_name)) over (partition by a.e_id order by b.d_id nulls first) when a.e_name then null else max(a.e_name) end e_name
  4       , b.d_id
  5       , b.d_num
  6       , b.d_name
  7    from a
  8       , b
  9   where a.e_id = b.e_id
 10   group by a.e_id
 11       , a.e_num
 12       , a.e_name
 13       , rollup((b.d_id, b.d_num, b.d_name))
 14   order by a.e_id
 15       , b.d_id nulls first
 16  /

      E_ID      E_NUM E_N       D_ID      D_NUM D_N
---------- ---------- --- ---------- ---------- ---
         1        100 ABC
                                   1        300 ABC
                                   2        400 DEF
         2        200 DEF
                                   3        500 GHI
                                   4        600 JKL

6 rijen zijn geselecteerd.

Kind regards
Rob.

Tags: Database

Similar Questions

  • Ask questions about the functionality of EA8500 MU-MIMO

    Dear Linksys

    I bought EA8500, and it arrived today.

    I have two questions about the functionality of MU-MIMO of EA8500 AP.

    1. I want to compare the performance between SU-MIMO and MU-MIMO, but there is no option to control this feature in the router admin page. Is that one of the possible ways?

    2 EA8500 supports 1733 Mbps wireless speed, but it resembles the speed of 1 Gbps ethernet cable.

    This router supports really speed 1 Gbps ethernet? or y at - it an option to support more throughput as the aggregation of links?

    Thank you

    Hi, hyeonu. For your first query, it is not possible because there is no option to disable the feature of MU-MIMO on your Linksys EA8500 router. In addition, with regard to your second, you can get a higher throughput of 1 Gbps since this is the maximum capacity of your ethernet connection.

  • An error occurred when DNS was questioned about the resource record (SRV) service location used to locate a domain controller Active Directory (AD DC) for the domain 'HAMI. LOCAL ".

    An error occurred when DNS was questioned about the resource record (SRV) service location used to locate a domain controller Active Directory (AD DC) for the domain 'HAMI. LOCAL ".

    The error was: "an existing connection was to be closed by the remote host".
    (0 x 00002746 WSAECONNRESET error code)

    The query was for the SRV record for _ldap._tcp.dc._msdcs. HAMI. LOCAL

    Hello

    Your question of Windows 7 is more complex than what is generally answered in the Microsoft Answers forums. It is better suited for the IT Pro TechNet public. Please post your question in the Forums TechNet Windows 7 Technet.

    Here is the link:
    http://social.technet.Microsoft.com/forums/en-us/w7itpronetworking/threads

    Hope this helps

  • Windows 7 starts questions about mac and office 2010 following an installation

    It's a long cut as short as vent. I've been miss sold a record of upgrade of windows 8 full disk-shaped, with norton and office 2010. My goal of creating windows on my mac for a course I'm taking. After that know I need windows 7, I bought it online. I created a partition of 80g on my mac charge windows 7, then norton. Until I loaded the office that I was invited to perform the update from apple in the windows software 7. Note before I installed norton, I load boot camp mac utilities according to the instructions. So, followed by all as should be. The prompt update from apple was quick time, iTunes and airport, I checked all and then updated. Then I loaded office 2010 and obtained throughout the process from the Microsoft site. On the last part of the installation, the installation failed due to a mistake of hanging iTunes. I tried again and again, I fixed the update to iTunes to add and remove the section of windows. Then, I got different errors. I decided to remove the whole score without uninstalling all programs again. When I get to the windows live, that this falls priming. I get various error messages whenever I try to start the process. As a header of Bank pool, fatal error and so on. Can anyone help? What is the damage?

    Hello

    Thanks for posting your query in Microsoft Community.

    Because the question is limited to Windows 7 on your Mac with Boot Camp, I suggest you contact Apple Boot Camp support for assistance.

    http://www.Apple.com/support/Bootcamp/

    I hope it helps. If you have any questions about Windows in the future, please let us know. We will be happy to help you.

  • Questions about LogMiner.

    Greetings. We use 11G and have installed OEM, but not DB Diagnostic Pack. I have a few questions about this utility:

    (1) can be used if the Pack diagnosis DB is not installed? I ask because I know that some of these utilities are not available if it is not.

    (2) I know that I need to enable logging extra to use it. Is there any show / General cool space that are associated with?

    (3) are there any air show with the help of LogMiner itself? In particular, I could see what happens if analyzes the current journal.

    (4) what the tool commonly used to determine what query performance caused problems for awhile?

    Thank you!

    1 Yes. It is not part of a pack.
    2 of course additional recording will result in repeat. The impact on performance is usually not noticeable.

    3 the result of mining is placed in the shared pool and queries on v$ logmnr_contents ask shared pool this may cause reduced performance.

    4 n ° do not forget that you are again mining. This means DML. Selects won't be in your recovery.

    -------------

    Sybrand Bakker

    Senior Oracle DBA

  • Question about cloud connectors

    We try to create a cloud to Eloqua connector. I read the CloudConnectorSampleGuide. I have a few questions about the expected data models and models of general implementation.

    Configuration of the connector of the cloud

    • The CC stores the identification information for each configured CC step Eloquya Eloqua?
      • What are the guidelines for the safe password storage? (I can't store the passwords as dirty one-way-hash that I need the password during execution.  The two-way hash gives an illusion of security but is not better than the plaintext).
    • When the CC is configured, where credentials should take place between the 1st and the 2nd screen? (i.e. as a hidden form field, session cookie cookie/etc.)
    • Eloqua warns the CC when a step is deleted?

    Cloud connector performance

    • What is the average number of steps configured Single that manages the CC?
    • Is it possible for a CC to have 1000 s and unique not configured to query?
    • What are the guidelines for scalability when the connector has to travel 1000 steps configured and survey? The CC requires a worker architecture to manage a large number of configured steps?
    • Are there best practices around the CC recovery hangs
      • For example: CC acquires the State waiting for members and moves to the current State. The CC blocks before the end of the stage. What is the approach suggested for

    recovery of the tasks in the current handling during recovery state? (assuming I have multiple instances of CC of the Eloqua poll). Is the connector of cloud supposed to maintain States of WIP to manage recovery correctly?

    Dmitry, once again, it is entirely to the developer.  When you add contacts to a stage, they will be processed in batches.  There is no limit to how much you add, and since they are left to step up to that dealt with by the connector, how long they sit depends on how long your connector takes to do its job.  Expectations, of course the faster you can deal with the best.

  • Question about business rules

    Hello

    I have a question about business rules. We have a lot of business rules for our planning application, and I wanted to know if there is a way to export all sort of business rule names in an Excel type file?

    Please, share your ideas.

    Thank you

    ~ Hervé

    You can run a query against the relational tables planning and get the names of BR from there.

    SELECT b.object_name

    Hsp_calc_mgr_rules has

    hsp_object b

    WHERE a.id = b.object_id;

    Cameron a quite handy planning SQL queries here http://camerons-blog-for-essbase-hackers.blogspot.com/search/label/stupid%20Planning%20queries

    I have a few http://www.orahyplabs.com/search/label/sql here (all plan not specific but)

    Concerning

    Celvin

    http://www.orahyplabs.com

  • Question about the OSB proxy service

    Hello

    I'm new to the world of SOA/OSB. I'm working on a POC from the OSB for our existing application. I have a question about the definition of the URL endpoint to the proxy service. It is possible to specify a generic url endpoint to a proxy service. Something like / SomeService / *. I tried and got errors. Is it possible to do somethig like that or it is a mistake on a conceptual level.

    Thank you

    anything you type in the uri of the endpoint of entry will be the contextroot to your service, so /SomeService should indeed be sufficient or as mentioned Pierluigi/SomeService/blabla is also valid (Betty is not a parameter query, but only a part of the contextroot)

    If you want to use a service like http rest

    / SomeService/blabla would still be the contextroot, and after that, you can use the query parameters

    / SomeService/badarou? var1 = test & var2 = test or/SomeService/blabla/employee/id/1

  • Question about DISCHARGE (expr, 1016) function

    Hello

    I have a question about the DUMP function, specifically the DUMP (expr, 1016). What character set is the function of report? The only logical answer seems to me the characters of data. The http://download.oracle.com/docs/cd/E11882_01/server.112/e17118/functions055.htm#SQLRF00635 docs it says: "by default, the return value contains no character set information. To retrieve the name of character of expr, add 1000 to all the values of previous format. "For example, a return_fmt of 1008 returns the result in octal * and provides the character set name of expr.*.

    I ask this question because a client complains that there a database with database EE8MSWIN1250 (obtained from DATABASE_PROPERTIES) characters and when I asked him to run a SELECT that could empty the contents of a column, he gave me this result:
    select dump(some_col, 1016) from some_table;
    
    Typ=1 Len=8 CharacterSet=AL32UTF8: c5,bd,c5,a0,54,45,53,54
    Now I can't imagine how the data can be stored in the AL32UTF8 character set if the characters of the database are EE8MSWIN1250. This scenario is still possible? I tried in vain to reproduce on my test database.

    I don't know if the column is defined with the characters of database or the national database characterset, but even if it was a NVARCHAR2, the dump function could not return AL32UTF8 since he is not a national character set.

    If anyone has an explanation, I will be very grateful.

    Thanks in advance and best regards,
    Swear

    1. to help with the confusion about the DUMP function: index realizes that the DUMP function can be performed in the remote database. Oracle tries to push as many functions as possible and semantically correct on the remote site. Therefore, it sends the statement of simple table on the remote site after stripping the DB link. In this case, the DUMP function sees the character set of the remote database and creates the resulting string of information. This string of AL32UTF8 to EE8MSWIN1250, as described in the note, but as all the characters in the string of information are pure ASCII, some codes are actually changed.

    Things get more interesting if you start to combine the tables of local and remote databases. For example, the following query is will normally return the character of local database defined for the two columns:

    select dump(xx,1016),dump(yy,1016) from (select x.dummy xx, y.dummy yy from dual x, dual@dblink y);
    

    This is because the first dual@dblink is transported to the local site and the join is performed here with application of DUMP.

    The following query returns the set for two columns of characters in remote database:

    select dump(xx,1016),dump(yy,1016) from (select x.dummy xx, y.dummy yy from dual@dblink x, dual@dblink y);
    

    This is because all the tables are remote and the entire query is sent to the remote database and y.

    The following query returns the remote character set thus:

    select dump(xx,1016),dump(yy,1016) from (select /*+driving_site(y)*/ x.dummy xx, y.dummy yy from dual x, dual@dblink y);
    

    Here, the DRIVING_SITE hint asks the database to perform the join in the database of the table, for example dual@dblink.

    2. to answer your question:

    Your understanding of the way of conversion is generally correct, but conclusions are not quite correct. In the scenario [client EE8ISO8859P2, EE8MSWIN1250 local database, remote database AL32UTF8], Eastern and Central European characters will work correctly, but the other characters to the remote database will not be (for example, French, Greek, Chinese). It is, I think, quite clear and is usually not a major problem, as usually only compatible languages EE8 are interesting for an EE8ISO8859P2 customer. However, in the scenario [customer AL32UTF8, EE8MSWIN1250 local database, remote database AL32UTF8], the problem becomes more visible. Having a taking customer support Unicode, you can recover some data French or Greeks of the remote database but you will fail as all of these characters will be "killed" by the conversion of distance at the local level (link DB conversion).

    EE8ISO8859P2 is also for the same group of languages, such as EE8MSWIN1250, indeed, but it lacks some interesting characters. The most important of them is the symbol of the Euro. Others are "' quotes, long dashes, TM symbol, and a few other less frequently used punctuation. Therefore, always define a database as EE8MSWIN1250, even if you run some clients (Unix) with EE8ISO8859P2. Do not run Windows with EE8ISO8859P2 clients, except for purposes of loading/generation of special file.

    -Sergiusz

  • A question about the REEL in sqlplus command

    Hi all


    I have a question about the order of the COIL and I would be grateful if you could kindly give me a helping hand. Consider the following sql script.
    SPOOL result.txt
    SELECT * FROM mytable;
    SPOOL OFF;
    It works pretty well, and all the contents of the table "MyTable" is exported to the textfile "result.txt". However, sqlplus also prints the number of lines
    Print after each query. So after you run this script, the end of the file, I always have a line like
    ...
    "20541 lines returned"
    How can I avoid this line (the number of returned rows) in my output file?


    Thanks in advance,
    Dariyoosh

    Type this command prior to winding.

    set feedback off
    

    Kind regards
    Prazy

  • Where can I ask a handful of general order questions about Firefox OS as a consumer and get the answers? (a forum or something similar)

    I have about seven questions about Firefox OS. I'm potentially interested in opting for a tablet that works instead of Android or iOS. I couldn't find a place to ask questions like that. Thank you!

    https://support.Mozilla.org/en-us/forums/Firefox-OS-English-Forum

    There is another option.

  • About a month ago I posted a question about iMovie and not being able to "share". I solved the problem thanks, so no more emails!

    About a month ago I posted a question about iMovie and not being able to "share". I solved the problem thanks, so no more emails!

    Hi Michael,

    If you want to stop receiving notifications by electronic mail, in the thread, that you have created, then I suggest that you follow the steps below:

    One time connected to the Apple Support communities, visit your mini profile and select manage subscriptions.

    Content

    To manage this content, you are currently subscribed and changing your preferences, select the content.

    Select next to see what content you are currently following.  Note that any thread you are responding you subscribe you automatically to this thread.

    You can select to terminate a subscription to a thread.

    Learn how to manage your subscriptions

    Take care.

  • Where and how do I ask questions about Email?

    The Commission opening thingy is complicated, I have trouble finding my way around it.  I don't know where or how questions about email.  Is there an easier way than trawling through all these icons?  Like a list or something - as you get on all other forums on the internet?

    It would be a good starting point: Mac mini

    Or the appropriate under MAC Os and system software section.

    You might also find this useful: find answers and new questions

  • Many questions about the HP 50 g

    I just ordered a HP 50 g graphic calculator! I have a few questions about this so hang on tight! What is the USB connector on the calculator? Mini-USB, micro USB, or is it a connector owner, "custom". Then, it would be possible to connect a keyboard to the HP 50 g by using the USB Port? Is there a program that would make this possible? (I doubt it would work if you plug it..) I have a Mini-USB to female USB 2.0 connector. So I could just plug the keyboard right, provided that the port on the calculator is a Mini-USB Port. If this is not so that I could use my female to female USB adaptor to connect the keyboard.

    Thanks for your help,

    Zekelegge

    Hi!, zekelegge:

    Welcome to Forum!

    The only printer I use, 50G calculators, 48GII, 39GS and 17BII +, as well as many former models, such as the 48 s/SX/G/G + / GX, 38 G, 39 G, 42, 41 C/CV/CX and 28 C/S, is the infrared printer HP 82240 b. If you can use the emulator HP50G, on the PC, the simulator of the printer, you can download, since... http://www.HPCalc.org/details.php?id=7386

    The printer... HP 82240 B

    The cable series...

    The description... http://www.allenwan.com/hpcalcserialcable/

    The original cable...

  • Question about warranty after exchanges of RAM on Satellite module series

    Hello together,

    I have a question about the warranty. My laptop is 5 months old and now I want to improve it with more RAM. I want to do it myself, and now I'm wondering if the warranty will be getting hurt.
    Thanks in advance for your answers.

    Concerning

    TiG3r

    For new models of laptops the RAM upgrade described in s operating manuals. It is public act and it shows the owner of the notebook how do RAM upgrade only.

    If Toshiba offers something like this he won't have the negative influence of valid warranty.
    Buy a compatible module and RAM upgrade.

    Bye and good luck!

Maybe you are looking for

  • How can I get American English spellchecker working when my location is Canada?

    I have recently come back Canada formula States. After my place in the Canada, I found that I had lost access to US-spellchecker (which I still need).  I looked at various system preferences and have not yet seen how to get back the Canadian spelling

  • Software provided

    Hello, I have a note from microsoft 2003 is already installed on my new laptop, I put on my another desktop at home, however it did not come with a CD, but maybe in the recovery disc, can anyone tell if I can copy a note to transfer it to my other co

  • Adapter DisplayPort to VGA resolution problem

  • crashed during the update does not start now

    my computer laptop gateway arrested during an update (not sure which). It does not start, I get a file missing or corrupt ntoskrnl.exe error. My repair disc does not work either, I read in the forum vista repair disks are not recognized if you instal

  • My Photosmart 7510e, guard print vertical lines

    I had my Photosmart 7510e 11 months and sometimes I get thin black vertical lines on the photos.  I tried to realign the heads, cleaning the heads, change the paper and replace the inks, I use genuine HP ink but it still keeps ENTERED.  I wouldn't wa