Hierarchical Oracle or MS SQL data

This query to MSSQL

SELECT  AreaID ,  
        AreaName ,  
        AreaSeq ,  
        ISNULL(( SELECT TOP 1  
                        t1.AreaName  
                 FROM   dbo.Area t1  
                 WHERE  t1.AreaSeq > dbo.Area.AreaSeq  
                 ORDER BY t1.AreaSeq  
               ), '') AS AppearBeforeArea ,  
        ISNULL(( SELECT TOP 1  
                        t2.AreaSeq  
                 FROM   dbo.Area t2  
                 WHERE  t2.AreaSeq > dbo.Area.AreaSeq  
                 ORDER BY t2.AreaSeq  
               ), -1) AS AppearBeforeSeq  
FROM    dbo.Area  
ORDER BY Area.AreaSeq;  

Gives this result

sqlseqnoqry.PNG

In Oracle 12 c


Create a Table Script:

create table Area(  
AreaID Number(5,0),  
AreaName Varchar2(50 char) ,  
AreaSeq Number(5,0)  
);

Insert data:

Insert Into Area Values(1,'Shastri Nagar', 0);  
Insert Into Area Values(3,'Saraswati Nagar', 1);  
Insert Into Area Values(2,'Sardar Pura', 2);  
Insert Into Area Values(5,'Sojati Gate', 3);  
Insert Into Area Values(4,'Polo Ground', 4);  

I tried with this hierarchical query but have no idea how to extract columns of rows child/Leaf;

SELECT    AREAID    , AREANAME    , AREASEQ    
FROM Area
START WITH AREASEQ  = 0    
CONNECT BY PRIOR AREASEQ  < AREASEQ    
ORDER SIBLINGS BY AREASEQ ;    

I use Oracle 12 c;

My Question is can I how ResultSet even return with Oracle query without using the service?

No need for the recursive query... just use an analytic function:

WITH box (AreaID, AreaName, AreaSeq)

(SELECT 1, 'Shastri Nagar', 0 double UNION ALL)

SELECT 3, 'Saraswati Nagar', 1 FROM dual UNION ALL

SELECT 2, "Sardar Pura", 2 FROM dual UNION ALL

SELECT 5, "Door of Sojati", 3 FROM dual UNION ALL

Select the OPTION 4, 'Polo Ground', 4 DOUBLE)

SELECT areaId, name of the area, AreaSeq

, lead (areaName) OVER (ORDER BY AreaSeq ASC) AS beforeAreaName

, lead (areaSeq, 1, -1) OVER (ORDER BY AreaSeq ASC) AS beforeAreaSeq

area

/

HTH

Tags: Database

Similar Questions

  • In general, is it better to use java.sql.Date and java.sql.Timestamp instead of oracle.jbo.domain.Date?

    Hello world

    During playback of Oracle ADF Real World Developer's Guide, I noticed the dates match occurring in JDeveloper is different from what is the list in the book. JDeveloper is failing to oracle.jbo.domain.Date, but according to the book:

    DATEjava.sql.DateDATE type is mapped to java.sql.Date if the column in the table is a no time didn't need information zone.
    DATEjava.sql.TimestampDATE type is mapped to java.sql.Timestamp if the column in the table has a component "time" and that the client needs to zone information.
    TIMESTAMPjava.sql.TimestampThe TIMESTAMP type is mapped to java.sql.Timestamp if nanosecond precision is used in the database.

    In general, is it better to use java.sql.Date and java.sql.Timestamp instead of oracle.jbo.domain.Date? Using java.sql.Date and java.sql.Timestamp could save me some headaches conversion date. And, is there a place in JDeveloper to display these maps? I looked around and didn't see anything.

    Thank you.

    James

    User, what version of jdev we are talking about?

    In GR 11, 1 material versions db types date and timestamp are mapped to types of domain data that represents a wrapper for the native data types. The reason was that the framework can work with the domain types regardless of the underlying data type.

    Since Oracle 11 GR 2 maps the types DB to java types (default selection, you can change it when you create a model project, you can set the Data Type Mapping). Once the pilot has business components define you cannot change this setting it would break existing components such as eo or vo.

    So if you are working wit 11 GR 1 subject, you must use the domain types, if you work with GR 11, 2 or 12 c, you can use the domain types, but it is recommended to use the java type mapping.

    Timo

  • Loading data from Oracle to MS SQL SERVER

    Hello

    Source: Oracle
    Target: MS SQL
    ODI:11 g


    I want to create an interface that loads the data from the source table in Oracle in the target table in MS SQL Server. Can any body tell me what LKM, IKM and CKM I use for the same.

    Any help will be appreciated.

    I thank you,
    Shrinivas

    Hi gisele, you can follow below KMs

    1 LKM SQL for SQL

    2 CKM ORACLE

    3 IKM SQL Incremntal update (Insert and update) / IKM SQL command APpend (insert only)

    It will be useful.

    Thank you

  • The maximum size of the model in SQL Data Modeler?

    Hello

    The number of objects is the maximum value that can be used in a model in SQL data maker. I reverse engineered a scheme (see previous posts - thank you to all that helped) which contains 1000 + tables (a candidate for remanufacturing if ever I saw a!) but the Data Modeler is struggling to display them and performs very slowly. I can pull the same schema in the Oracle Designer and that works well, as ERwin-t - y at - it something I can do to improve the performance of the Data Modeler?

    Or people would recommend cutting the model into smaller pieces, which will be a little difficult because it's a bit of a rat's nest.

    John

    Hi John,.

    You can try to fix the memory usage - Re: problem of memory with large model

    And you may have better performance if divide you large diagram in subviews.

    Philippe

  • Problem with the two EA DEVELOPER SQL DATA MODELING 3.0.0.665 and 3.1

    I created a model of very large data using SQL Developer data 3.0.0.665 and 3.1 EA maker. Its having a lot of check constraints. Whenever I am the design of the fence and the DOF and reopening export to import the DDL file failure to import completely check constraints. It is important to check constraints, but without any range of values inside. Its very frustrating because whenever you open import ddl, you must manually add again all the details of data check range constraint.

    OS: Windows XP.
    Check in the two EA Developer SQL Data Modeler 3.0.0.665 and 3.1

    -------------------------------------------
    Here are the contents of the .dmd file.
    -------------------------------------------
    * <? XML version = "1.0" encoding = "UTF - 8"? > *.
    * < OSDM_Design class = "oracle.dbtools.crest.model.design.Design" name = 'Admin_Panel' id = "9BE18B0A-6C67-2E5B-00DE-BD8312189ECB" version = "3.41" > * "
    * < createdBy > administrator < / createdBy > *.
    * < Createduserid > 2011-10-17 08:32:18 UTC < / Createduserid > *.
    * < Admin_Panel ownerDesignName > < / ownerDesignName > *.
    * < false capitalNames > < / capitalNames > *.
    * < designId > 9BE18B0A-6C67-2E5B-00DE-BD8312189ECB < / designId > *.
    * < / OSDM_Design > *.

    -------------------------------------------------------------------------------
    An example how the check constraints to get dirty.
    -------------------------------------------------------------------------------
    Initial check constraint is as below:
    ======================
    ALTER TABLE test_table
    ADD CONSTRAINT Active_Flag_ck
    CHECK (Active_Flag IN ('A', 'I'))
    *;*

    Below how it occurs once I have imported the ddl and re-export:
    ============================================
    ALTER TABLE test_table
    ADD CONSTRAINT Active_Flag_ck
    (CHECK)
    *;*

    I'm in trouble as I already in the middle of the my development using SQL Developer Data Modeler.

    Please help me soon.

    Jean

    Hi John,.

    Every time I'm fence design and export the ddl and reopening through the import of the DDL file

    Why are you doing this? Once the DDL file is imported and then save the drawing and open simply saved design, no need to generate the DDL and import it every time that you start Modeler data.
    On the list of values - forced as this CHECK (Active_Flag IN ('A', 'I')) are imported as constraint check plain and not as a list of values.
    There are the more specific elements import of check constraint - they are defined as type database constraint that you select during the import. Accordingly if you import your DOF as Oracle 10 g DDL, then you will get forced correct check in DDL generated for Oracle 10 g and Oracle 11 g. Constraint of evil will be generated for Oracle 9i. You can move the constraint for Oracle 9i (in the check constraint dialog box) or generic if it can be treated as such constraint.

    I logged for DOF bad bug.

    Philippe

  • java.lang.ClassCastException:String cannot be cast to java.sql.Date

    I have a date component. MinValue named Id2 and the following code is to run a class cast exception indicating that the string value cannot be cast to a date sql

    java.sql.Date dateNeeded = (java.sql.Date) this.getId2 () .getValue ();

    can someone help me to overcome this problem.

    Thanks and greetings
    Janak

    Published by: new_to_ORACLE on February 18, 2011 16:56

    Published by: new_to_ORACLE on February 18, 2011 16:58

    the Date attribute is of type object oracle.jbo.domain.Date
    so, first try to cast to oracle.jbo.domain.Date. then to java.sql.Date object

    If you need to cast to another Date object, see this site:
    http://www.ecotronics.ch/webdesign/javadate.htm

    Published by: M.Jabr on February 19, 2011 11:53

  • Foreground of Oracle process to access data under Linux files

    As far as I know, processes user in an Oracle database running the application code, but the processes of database running Oracle database server code (server process analyze and execute the SQL statements issued through the app, read data of data files blocks and return the results to the application.) Background treats the archive logs, update the headers of all the data files to save the details of the control point, written content of the buffers of data files, runs the recovery if necessary, etc.)

    However, I could see the oracle user processes to access data files in my Oracle database. When I look for the processes to access data belonging to the tablespace files "recprov", I get the following:

    [root@ymir ~] # lsof | grep recprov
    Oracle Oracle 465 11u REG 8.18 6291464192 /ora2/oradata/essepr3/recprov_tb_01.dbf 48496658
    Oracle Oracle 465 13u REG 8.18 4823457792 /ora2/oradata/essepr3/recprov_tb_02.dbf 48496659
    Oracle Oracle 465 15u REG 8.18 4823457792 /ora2/oradata/essepr3/recprov_tb_02.dbf 48496659
    Oracle Oracle 964 11u REG 8.18 4823457792 /ora2/oradata/essepr3/recprov_tb_02.dbf 48496659
    Oracle Oracle 964 13u REG 8.18 4823457792 /ora2/oradata/essepr3/recprov_tb_02.dbf 48496659
    Oracle Oracle 964 14u REG 8.18 6291464192 /ora2/oradata/essepr3/recprov_tb_01.dbf 48496658
    Oracle Oracle 13364 14u REG 8.18 4823457792 /ora2/oradata/essepr3/recprov_tb_02.dbf 48496659
    Oracle Oracle 13364 76u REG 8.18 6291464192 /ora2/oradata/essepr3/recprov_tb_01.dbf 48496658
    Oracle Oracle 16445 17u REG 8.18 4823457792 /ora2/oradata/essepr3/recprov_tb_02.dbf 48496659
    Oracle Oracle 16445 18u REG 8.18 6291464192 /ora2/oradata/essepr3/recprov_tb_01.dbf 48496658
    Oracle Oracle 20522 REG 8.18 4823457792 /ora2/oradata/essepr3/recprov_tb_02.dbf 48496659 82uW
    Oracle Oracle 20522 REG 8.18 6291464192 /ora2/oradata/essepr3/recprov_tb_01.dbf 48496658 122uW
    Oracle Oracle 20532 44u REG 8.18 4823457792 /ora2/oradata/essepr3/recprov_tb_02.dbf 48496659
    Oracle Oracle 20532 75u REG 8.18 6291464192 /ora2/oradata/essepr3/recprov_tb_01.dbf 48496658
    Oracle Oracle 20534 17u REG 8.18 4823457792 /ora2/oradata/essepr3/recprov_tb_02.dbf 48496659
    Oracle Oracle 20534 79u REG 8.18 6291464192 /ora2/oradata/essepr3/recprov_tb_01.dbf 48496658

    As you can see, there are 7 oracle processes that access data files: 4 processes user and 3 background processes:

    [root@ymir ~] # ps - ef
    ...
    Oracle 465 1 Jan27 0? 00:00:23 oracleessepr3 (LOCAL = NO)
    Oracle 964 1 Jan27 0? 00:00:25 oracleessepr3 (LOCAL = NO)
    Oracle 13364 1 0 Jan13? 02:45:02 oracleessepr3 (LOCAL = NO)
    Oracle 16445 1 0 Jan21? 00:00:05 oracleessepr3 (LOCAL = NO)
    20522 1 0 2009 Oracle? 00:09:59 ora_dbw0_essepr3
    20532 1 0 2009 Oracle? 00:04:24 ora_ckpt_essepr3
    20534 1 0 2009 Oracle? 00:04:10 ora_smon_essepr3
    ...

    And I confirmed this information from the data base repository:

    SQL > select p.SPID, SSE. TYPE, SSE. Username, SSE. MACHINE, SSE. PROGRAM
    session $ v ESS, v$ process p
    where p.SPID (465, 964, 13364, 16445, 20522, 20532, 20534) and SES. PADDR = p.ADDR;

    USER NAME OF TYPE SPID MACHINE PROGRAM
    ----- ----------- --------------- --------------- ---------------------------------------------------------
    20522 BACKGROUND dbserver (DBW0) oracle@dbserver
    20532 BACKGROUND dbserver oracle@dbserver (CKPT)
    20534 BACKGROUND dbserver oracle@dbserver (SMON)
    13364 USER DBSNMP dbserver emagent@dbserver (TNS V1 - V3)
    964 RECPROV USER appserver JDBC Thin Client
    16445 USER SYSTEM userPC PlSqlDev.exe
    465 RECPROV USER appserver JDBC Thin Client

    * RECPROV is the name of the user of the application database.

    My question is, why are there user processes to access data files? I think that it does not match the process architecture defined by Oracle. And most importantly, it does not mean a security leak in the database?

    DB version: 10.2.0.3, dedicated
    The Linux Version: Linux 2.6.18 - 53.el5xen #1 SMP Sat Nov 10 19:46:06 EDT 2007 x86_64 x86_64 x86_64 GNU/Linux

    Thanks in advance

    Hello

    There seems to be some confusion, even in the Oracle documentation, in terms of nomenclature.

    Think of it this way. There is the client program that connects to Oracle, such as SQL * Plus, Toad, custom, etc. written application. This program runs on the client. This may or may not be on the database server.

    Then there's the Oracle database server process. They run always on the database server. These processes are of two types, the USER and the background.

    You can see:

    SQL> select background,count(*) from v$process group by background;
    
    B   COUNT(*)
    - ----------
              65
    1         37
    

    Here are copies of the file binary oracle attach directly to the SGA and interact with database files. The binary oracle works with several different "personalities" based on the different purposes, he is currently serving. The type of background process, are divided into different specific methods for specific purposes.
    Yet once, observe:

    SQL> select pname from v$process where background = 1;
    
    PNAME
    -----
    PMON
    VKTM
    GEN0
    DIAG
    DBRM
    PING
    PSP0
    ACMS
    DIA0
    LMON
    LMD0
    
    PNAME
    -----
    LMS0
    LMS1
    RMS0
    LMHB
    MMAN
    DBW0
    DBW1
    LGWR
    CKPT
    SMON
    RECO
    
    PNAME
    -----
    RBAL
    ASMB
    MMON
    MMNL
    MARK
    LCK0
    RSMN
    GTX0
    SMCO
    W000
    RCBG
    
    PNAME
    -----
    QMNC
    Q001
    CJQ0
    Q005
    
    37 rows selected.
    

    Thus, each background process serves a different purpose. For example. DBW0 concerns only to write data from the buffer cache data files and maintaining all data structures associated with it. Each background process above serves a different purpose, I will not go into all. Generally, the background processes start up time of instance startup, even though some may be started on demand, at a certain time after the start of the proceeding.

    Now, consider a dedicated server model. When you connect to the database by using SQL * Plus, for example, you run the binary "sqlplus". Assume that you are connected via SQL * Net. In this case, sqlplus connects to the listener, the listener creates an oracle server process, type 'USER '. This process always runs on the database server. It runs under the user 'oracle', and it provides your real and direct interface to the database. This user can interact with the database and read the database files directly.

    Mainly, your server processes the USER will read the data from the cache buffers and, in the case of an absence of cache, will read the data in the data files and loading into the buffer cache. In addition, according to the code path, it can directly read or write to the datafiles, bypassing the buffer cache.

    So, the bottom line, all server (USER and BOTTOM) processes, interact with the database and associated files. The code of client program (sqlplus, Toad, etc.) NEVER directly interacts with the database.

    Hope that things cleared up.

    -Mark

  • How do to know all the tables on peoplesoft (on Oracle 8.1) with data

    I need to know all the tables on peoplesoft (on Oracle 8.1) < strong > with < facilities > data
    and ignore the tables without data.

    It takes to write a pl/sql procedure or is there an easy solution?
    I wrote an example of code, but I am disconnected programming
    for the long and I need help.
    Thanks in advance
    Pls answer
    _______________
    Cursosr curtab is select table_name from dba_tables;
    curtab() loop
    Select count (*) x from curtab;
    If x & gt; 0
    UTL_FILE. Write ('curtab')
    on the other
    null;
    endif;
    end loop;
    ____________________

    Julia wrote:
    I need to know all the tables on peoplesoft (on Oracle 8.1) with data
    > & ignore tables without data.
    >
    > It takes to write a pl/sql procedure or is there an easy solution?
    > I wrote a code example, but I am disconnected programming
    > for a long time and I need help.
    > Thanks in advance
    > Pls answer
    > _______________
    > Cursosr curtab is select table_name from dba_tables;
    > curtab() loop
    > select count (*) x from curtab;
    > If x > 0
    > utl_file.write ('curtab')
    > other
    > null;
    > endif;
    > end of loop;
    > ____________________

    Consider using the user_tables and it works the relevant schema rather than dba_tables breast or of all_tables as these allows you to specify the schema name too will require.

    set serveroutput on;
    
    DECLARE
      cursor curtab is
        select table_name
        from   user_tables;
      --from   all_tables where owner = '';
      v_cnt NUMBER;
    BEGIN
      FOR t IN curtab
      LOOP
        EXECUTE IMMEDIATE 'select count(*) from '||t.table_name INTO v_cnt;
        IF v_cnt > 0 THEN
          DBMS_OUTPUT.PUT_LINE(t.table_name);
        END IF;
      END LOOP;
    END;
    /
    

    Or...

    Ensure that statistics were collected for the schema and examine the value of num_rows in the user_tables view. ;)

  • Does not not for java.sql.Date sort field

    Hi Experts ADF,

    JDev version 11.1.1.7.0

    I use a POJO based datacontrol, who is dragged like a table on page JSFF. One of the field is a java.sql.Date data type in POJO.

    So for example in the table 4 values are there to this date field as

    2.2.2014

    3.2.2014

    31.1.2014

    to 31.12.2013

    So while sorting in ascending order, it should come as below

    to 31.12.2013

    31.1.2014

    2.2.2014

    3.2.2014

    And vice-versa.

    But if I click on sort it sorts by the first 2 digits only, and I'm under results for sorting (ascending)

    2.2.2014

    3.2.2014

    31.1.2014

    to 31.12.2013

    Please suggest on this. Thanks in advance.

    Thank you

    Animesh

    Hi This sorting has been solved by changing of java.util.Date.

    Yes his watch to the client as an outputText inside the table. Sorting option is there for af:column.

    Thank you

    Roy

  • Difference between Oracle database and SQL or SQL Developer +?

    Hello
    I am very very new to Oracle... Only yesterday I installed Oracle 11 G for learing... I found to create an Oracle database

    Oracle Db11gHome1 = > Configuration and Migration Tools = > Database Configuration Wizard
    ... blah... blah... blah... Success... I created...

    But I found the menus

    Oracle Db11gHome1 = > application development = > SQL Developer
    Oracle Db11gHome1 = > = application development > SQL Plus

    And so I get confused... I know SQLSERVER 2008... etc... to create databases... So the above said two is for what purpose?
    Anyone can show me a route for this spirit of quarrels?

    Thank you

    Hello

    Welcome to the world of Oracle.

    SQL Developer: http://www.oracle.com/technetwork/developer-tools/sql-developer/what-is-sqldev-093866.html

    SQl more: http://docs.oracle.com/cd/B13789_01/server.101/b12170/qstart.htm

    These docs will give an initial advance for these tools.

    Something in common between these two tools is: both are used to access the Oracle database.

    Thank you
    Navneet

  • How to count the number of columns in an oracle table using sql

    How to count the number of columns in an oracle table using sql

    You must put the name of the table in capital letters

    As

    SELECT COUNT(1)
      FROM user_tab_columns
    WHERE table_name = 'EMP';
    
    or
    
    SELECT COUNT(1)
      FROM user_tab_columns
    WHERE table_name = UPPER('Emp');
    

    Concerning
    Arun

  • How to move Oracle APPS 12 configuration data to the new environment of production of 12 APPS

    Dear all

    I need to know, how we can move from Oracle APPS 12 configuration data to the new environment of production of 12 APPS? What is the safe and easy way, we do not want to make the new facility of 12 APPS and reinstalling things...

    see you soon

    Hello

    The scenario above is correct and should work fine. Make sure that the central source and instances of the target are the same patch upgraded.

    Kind regards
    Hussein

  • How normalization code in oracle 10 in sql/pl-sql

    If any body help manage how the standaridazation code in oracle 10g in sql/pl-sql.

    post your coding standards

  • [SOLVED] Export Oracle SQL Data Modeler is missing a PRIMARY KEY on the DDL script

    I use data 4.1.888 maker to create an ER diagram and generate a DDL her script.

    The diagram contains more than 40 paintings, most of them have a primary key defined.

    For some reason any there is a table that has a primary key defined, but which is ignored when I export the model to a DDL script.

    It is the "wrong" key (even if it is checked that it is not found on the generated DDL script):

    4faS5.png

    This is where the key is set:

    O5mPb.png

    And it is the preview of the DDL (Yes, primary key up there shows):

    SrwMu.png

    This is what happens if I try to generate the DDL for just this (still not generated primary key) table:

    MljUm.png

    Has anyone had the same problem? Any ideas on how to solve it?

    There is no error in the log file, but when I run the generated DDL script there, and then I realized that I was doing something wrong:

    The table MEMBERS had a mandatory foreign key from another table, which in turn had a mandatory key against MEMBERS himself.

    So even if I could generate this primary key on members myself, and then run the the constraint definition that returned an error on the DDL script, I could not perform an insert operation on any of these two tables because of the constraint.

    I revised my design and realized relationships was not mandatory. I unchecked the mandatory box on the definition of the constraint and everything went well.

    I could reproduce the problem and the solution on a diagram with only two tables, so I'm sure that's it.

    Anyway, the Data Modeler is "a failed" silently in this kind of situation. It should be fairly obvious to an experienced designer that I was doing something wrong, but it is not so obvious when you deal with dozens of tables and all their relations and this is your first time using the Modeler.

    Thanks for your reply :-)

  • How to perform account on a Table hierarchical Oracle based on the Parent link

    Hello


    I have the following to Oracle 11 g R2 hierarchical table definition:


    Table Name: TECH_VALUES:
      ID,
      GROUP_ID,
      LINK_ID
      PARENT_GROUP_ID,
      TECH_TYPE

    Above the hierarchical table definition, some examples of data might look like this:


    ID      GROUP_ID      LINK_ID      PARENT_GROUP_ID      TECH_TYPE 
    ------- ------------- ------------ -------------------- --------------
    1       100           LETTER_A     0
    2       200           LETTER_B     0
    3       300           LETTER_C     0
    4       400           LETTER_A1    100                  A 
    5       500           LETTER_A2    100                  A 
    6       600           LETTER_A3    100                  A 
    7       700           LETTER_AA1   400                  B 
    8       800           LETTER_AAA1  700                  C 
    9       900           LETTER_B2    200                  B 
    10      1000          LETTER_BB5   900                  B 
    12      1200          LETTER_CC1   300                  C
    13      1300          LETTER_CC2   300                  C
    14      1400          LETTER_CC3   300                  A
    15      1500          LETTER_CCC5  1400                 A
    16      1600          LETTER_CCC6  1500                 C
    17      1700          LETTER_BBB8  900                  B
    18      1800          LETTER_B     0
    19      1900          LETTER_B2    1800                 B 
    20      2000          LETTER_BB5   1900                 B 
    21      2100          LETTER_BBB8  1900
                     B


    Keeping in mind that there are only three Types of technology, i.e. A, B and C, but could not span on different LINK_IDs , how can I do a count on these three different TECH_TYPEs based solely on the ID of parent link where the parent group id is 0 and there are children below them?

    NOTE: It is also possible to have parents in dual link ID such as LETTER_B and all values of children but different group ID.

    I'm basically after a table/report query that looks like this:

    Link ID        Tech Type A         Tech Type B          Tech Type C
    -------------- ------------------- -------------------- -------------------
    LETTER_A      
    3                   1                    1
    LETTER_B      
    0                   3                    0
    LETTER_C      
    2                   0                    3
    LETTER_B      
    0                   3                    0

    Be hierarchical and my table can consist more of 30 000 files, I must also ensure that performance to produce the report above shown here query is fast.

    Obviously, in order to produce the report above, I need to gather all necessary County outages based on TECH_TYPE for all parents of the link id where the PARENT_GROUP_ID = 0 and store it in a table according to the guidelines of this report layout.

    Hope someone can help with maybe a combined query that performs the counties as well as stores the information in a new table called LINK_COUNTS, which will be based on this report. Columns of this table will be:

    ID,

    LINK_ID,

    TECH_TYPE_A,

    TECH_TYPE_B,

    TECH_TYPE_C

    At the end of this entire requirement, I want to be able to update the LINK_COUNTS table based on the results returned by the sample data above in a SQL UPDATE transaction as the link ID parent top-level already exists within my table LINK_COUNTS, just need to provide values for breaking County for each parent node link , i.e.

    LETTER_A

    LETTER_B

    LETTER_C

    LETTER_B

    using something like:

    UPDATE link_counts

    SET (TECH_TYPE_A,TECH_TYPE_B,TECH_TYPE_C) =

       (with xyz  where link_id = LINK_COUNTS.link_id .... etc

    Which must match exactly the above table/report

    Thank you.

    Tony.

    Hi, John,.

    Thanks for posting the sample data.

    John Spencer wrote:

    ...  If you need to hide the ID column, then you could simply encapsulate another external query around me. ...

    Or simply not display the id column:

    Select link_id, -id,

    Count (case when tech_type = 'A' end then 1) tech_a.

    Count (case when tech_type = 'B' then 1 end) tech_b,.

    Count (case when tech_type = "C" then 1 end) tech_c

    of (connect_by_root select link_id link_id,)

    the connect_by_root ID, tech_type

    of sample_data

    Start with parent_group_id = 0

    connect prior group_id = parent_group_id)

    Link_id group, id

    order by link_id, id;

    Same results, using SELECT... PIVOT

    WITH got_roots AS

    (

    SELECT CONNECT_BY_ROOT link_id AS link_id

    Id CONNECT_BY_ROOT ID

    tech_type

    OF sample_data

    START WITH parent_group_id = 0

    CONNECT BY PRIOR group_id = parent_group_id

    )

    SELECT link_id, tech_a, tech_b, tech_c

    OF got_roots

    PIVOT (COUNT (*)

    FOR tech_type IN ('A' AS tech_a

    'B' AS tech_b

    'C' AS tech_c

    )

    )

    Id ORDER BY link_id

    ;

Maybe you are looking for

  • Why do I may for listening to my own music?

    Hello My daughter has an iPad, where she purchased songs in iTunes. She wants to listen to these songs also on his phone of Samsung. When she tries to download music from Apple app store Google play, she needs to buy a subscription to Apple's music t

  • Addition of 3 tools

    Hello. Forgive me if I don't fix them all, but there are two tools available when working in the APPLICATION. For example, we can have the selection available and more marquee tool tool to fade, but when I worked in Logic 9 I could make 3 available a

  • Satellite Pro graphic problem - BSOD - 100-347?

    Hi - my son has problems with its graphics drivers laptop I think. At startup it dispays small blue pixels to scratches on the screen. He got a BSOD, but it went so fast, we had trouble reading it - he said something about the audit of an update of t

  • Problem connecting USB of Lenovo S890

    Hi, I just bought S890 a few days... and I wanted to connect to the computer with the help of the USB but it always show it me and I tried this also http://forums.Lenovo.com/T5/Lenovo-phones/S890-ideatool-connection-problem/TD-p/1083109 but it still

  • ERROR CODE 606 CAUSING FAILURE OF THE UPDATES OF WINDOWS 'IMPORTANT' 10

    Help, please!  I try to install the last "10 important updates" for Windows, which I was informed automatically.  I tried 4 times in 2 days now and each of them settled due to the 'error Code 606'.  When I click on "help", he pulls up "WindowsUpdate_