Child table child column count based on pareent table

Hi ,
I have requirement to generate a report .
based on parent table I want find out child table and child key count.
In the below query i will give parenet table name it will give child table details and child key details
"SELECT b.table_name as table_name , d.column_name, b.R_CONSTRAINT_NAME
FROM user_constraints a, user_constraints b, user_ind_columns c, user_cons_columns d
WHERE a.constraint_type = 'P' AND
a.CONSTRAINT_NAME = b.R_CONSTRAINT_NAME AND
b.CONSTRAINT_TYPE = 'R' AND
a.table_name = c.table_name AND
a.constraint_name = c.index_name AND
b.CONSTRAINT_NAME = d.constraint_name AND
a.table_name = 'TABLENAME' "
eg ; here I will give dept table name I want emp table details
Example output
Childtable. Childkey Count
EMP 10 5
EMP 20 10
EMP 30 5
.....etc.
Please any body has solution for my requirement please help me .
Thanks
Edited by: tmadugula on Oct 26, 2012 6:25 AM
Edited by: tmadugula on Oct 26, 2012 6:28 AM
Edited by: tmadugula on 26 Oct, 2012 11:08 AM
Edited by: tmadugula on 26 Oct, 2012 11:21 AM
Edited by: tmadugula on 26 Oct, 2012 11:30 AM

Is what you are really asking is how many FK point to a specific table? If so, then you do not need the join to user_ind_columns or to user_cons_columns. You just join user_constraints to itself on a.r_constraint_name = b.constraint_name and b.table_name = target_table
A FK has to point to the PK or UK of the referenced table so the number of columns pointed to will equal the number of columns in the constraint so I see no need to try to count the individual column references as it will equal the number of FK to the PK or UK constraint.
HTH -- Mark D Powell --

Similar Messages

  • How can I construct a list of text values in Table 2 from text values in Table 1:Column A, based upon a test value in Table 1:Column B?

    I am looking for a way to essentially import a select group of values from one table into another. If, for instance, I have a list of names in Column A and a list of colors in Column B, I would like to be able to compile a list of the names which coincide with each distinct color, and do so in a new table specific to that color. Probably an obvious solution, but I'm a relative newbie with Numbers and my spreadsheet experience is fairly limited so I apologize if this is embarrassingly rudimentary. Thanks in advance for any help you can give.

    You can extract a subset in a separate table by adding a helper index column to your table with the original data and using a formula in the separate table.
    But first, have you tried just using a filter on the table to view a subset of the data?  You would simply filter on a color in your Column B and would immediately see the names specific to that color in Column A.  And you could copy-paste those names elsewhere as needed.  No extra columns. No formulas. No fuss.
    SG

  • Join same table 3 times, count from two other tables

    Hi all!
    I have 3 tables
    RECORDS
    Id, Record_Id
    ITEMS
    Id, Record_Id
    ARTICLES
    Id, Record_Id
    I need to join RECORDS table 3 times R1,R2,R3 and get count of items R2 and R3 have and count articles that R3 has.
    R2 must have ITEMS and R3 must have items, R3 may have articles. R1 may have multiple children and R2 may have multiple children.
    Solution I'm using is following, but distinct makes it slow...
    select r1 as ParentRecordId,count(distinct i1) as Volumes,count(distinct i2) as Numbers, count(distinct a1) as Articles
    from
        select r1.id as r1,i1.id as i1,i2.id as i2,a.id as a1
        from records r1 inner join records r2 on r1.id=r2.record_id
        inner join records r3 on r2.id=r3.record_id
        inner join items i1 on r2.id=i1.record_id
        inner join items i2 on r3.id=i2.record_id
        left join articles a on a.record_id=r3.id
    ) as sel
    group by r1
    order by 1
    Regards
    Meelis

    Please post DDL, so that people do not have to guess what the keys, constraints, Declarative Referential Integrity, data types, etc. in your schema are. Learn how to follow ISO-11179 data element naming conventions and formatting rules. Temporal data should
    use ISO-8601 formats. Code should be in Standard SQL as much as possible and not local dialect. 
    This is minimal polite behavior on SQL forums. And thanks for no sample, too! 
    >> I have 3 tables <<
    No, you have three identical decks of 1950's punch cards written in bad SQL. 
    There is no such thing as a generic, universal “id” in RDBMS. It has to be the identifier of something particular. 
    Magical columns appear in your query. 
    There is no such concept as “child' and “parent” in RDBMS. That was network and hierarchical databases. We have referenced and referencing tables. 
    We do not use column positions in the ORDER BY cause; any change in the query used in the cursor will screw up everything. 
    Would you like to try again? 
    --CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
    in Sets / Trees and Hierarchies in SQL

  • Need data in Child table based on master table

    Need help in SQL :
    I have master table name called : AA
    Data is having :
    Date Display Name
    =====================
    10/3/2009 Q3 2009
    1/3/2010 Q4 2009
    1/13/2010 Q1 2010
    4/4/2009 Q1 2009
    7/4/2009 Q2 2009
    I have Child Table
    ===============================
    ID Date Name
    =======================================
    101 10/3/2009 AAAAA
    101 1/3/2010 AAAAB
    =====================================
    Reporting purpose, I need to have data in child table for every quarter.
    Problem is : I dont have data in child table for every quarter date.
    How I want : I want to create a view, which has data of child table along with all quarters, so that I can use that view in my report.
    Data I want in view :
    ID Date Name
    =======================================
    101 10/3/2009 AAAAA
    101 1/3/2010 AAAAB
    101 1/13/2010 NOT PRESENTED ( NEW ROW)
    101 4/4/2009 NOT PRESENTED ( NEW ROW)
    101 7/4/2009 NOT PRESENTED ( NEW ROW)
    I dont want to create any procedure for this, because evey time need to run the procedure to populate data in the view / table
    Thanks in advance

    the Above question is answered perfectly,
    I got some more extension to the above query.
    Initial Question:
    Need help in SQL :
    I have master table name called : AA
    Data is having :
    Date Display Name
    =====================
    10/3/2009 Q3 2009
    1/3/2010 Q4 2009
    1/13/2010 Q1 2010
    4/4/2009 Q1 2009
    7/4/2009 Q2 2009
    I have Child Table
    ===============================
    ID Date Name
    =======================================
    101 10/3/2009 AAAAA
    101 1/3/2010 AAAAB
    =====================================
    Reporting purpose, I need to have data in child table for every quarter.
    Problem is : I dont have data in child table for every quarter date.
    How I want : I want to create a view, which has data of child table along with all quarters, so that I can use that view in my report.
    Data I want in view :
    ID Date Name
    =======================================
    101 10/3/2009 AAAAA
    101 1/3/2010 AAAAB
    101 1/13/2010 NOT PRESENTED ( NEW ROW)
    101 4/4/2009 NOT PRESENTED ( NEW ROW)
    101 7/4/2009 NOT PRESENTED ( NEW ROW)
    I dont want to create any procedure for this, because evey time need to run the procedure to populate data in the view / table
    **New Question:*  :* I have got another parent for Child for ID's : Ex : 101
    Another Parent table: AP
    =====================
    ID
    =============
    101
    102
    103
    I want to show every quarter to this ID as well Child. ( I can partition from this id, but I need some data from Child also.)
    Data I want in view :
    ID Date Name
    =======================================
    101 10/3/2009 AAAAA
    101 1/3/2010 AAAAB
    101 1/13/2010 NOT PRESENTED ( NEW ROW)
    101 4/4/2009 NOT PRESENTED ( NEW ROW)
    101 7/4/2009 NOT PRESENTED ( NEW ROW)
    102 10/3/2009 NOT PRESENTED ( NEW ROW)
    102 1/3/2010 NOT PRESENTED ( NEW ROW)
    102 1/13/2010 NOT PRESENTED ( NEW ROW)
    102 4/4/2009 NOT PRESENTED ( NEW ROW)
    102 7/4/2009 NOT PRESENTED ( NEW ROW)
    103 10/3/2009 NOT PRESENTED ( NEW ROW)
    103 1/3/2010 NOT PRESENTED ( NEW ROW)
    103 1/13/2010 NOT PRESENTED ( NEW ROW)
    103 4/4/2009 NOT PRESENTED ( NEW ROW)
    103 7/4/2009 NOT PRESENTED ( NEW ROW)
    Thanks in advance

  • Finding column count with dynamic columns and dynamic tables

    I've done some PL/SQL for awhile now but was trying to devise a solution for the following problem:
    I wish to find the number of times a specific value for a column exists in all the tables that contain the field and I have access to see with the current user. The column name and value will be passed in via parameters.
    I was hoping to use something like
    select table_name from all_tab_columns where column_name = <variable table name>;
    then use the results from this to create a select statment based off the tables from the select above. I know the difference between dba_tab_columns and all_tab_columns - I want to make sure that I only retrieve the values i have access to.
    Can anyone point me to some guide / website / reference material I can read to catch up on the idea of creating this statment?
    Thank you.

    Hi,
    it's a test version.
    You can naturally tune it, but it seemed to work:
    declare
    pi_column VARCHAR2(30) := 'DEPTNO';
    pi_value VARCHAR2(4000) := '20';
    v_count NUMBER := 0;
    v_count_tab NUMBER;
    BEGIN
    FOR I IN (select owner, table_name from dba_tab_columns
              where column_name = pi_column
    LOOP
        EXECUTE IMMEDIATE 'SELECT count(*) FROM '||i.owner||'.'||i.table_name||
                          ' WHERE '||pi_column||' = :pi_value'  INTO v_count_tab USING pi_value; 
        v_count := v_count + v_count_tab;
    END LOOP;                   
    dbms_output.put_line(v_count);
    END;Regards

  • Add column to user defined type based on existing table

    Hello guys,
    I am trying to compile my function which returns a user defined type based on existing table. Throughout the initializing process though my query returns one additional column - SCORE(1). Here is my package:
    create or replace
    PACKAGE STAFF_AGENCY_PKG AS
    TYPE TYPE_SEEKER_TABLE IS TABLE OF TOSS.SEEKER%ROWTYPE;
    FUNCTION GET_SEEKERS(IN_KEYWORD IN VARCHAR2)
    RETURN TYPE_SEEKER_TABLE PIPELINED;
    END STAFF_AGENCY_PKG;
    create or replace
    PACKAGE BODY STAFF_AGENCY_PKG
    AS
    FUNCTION GET_SEEKERS(IN_KEYWORD IN VARCHAR2)
    RETURN TYPE_SEEKER_TABLE PIPELINED
    IS
    R_TBL TYPE_SEEKER_TABLE; -- to be returned
    BEGIN
    FOR R IN(
    SELECT Seeker.SEEKER_ID,
    Seeker.FIRSTNAME,
    Seeker.LASTNAME,
    Seeker.NATIONALITY,
    Seeker.ISELIGIBLE,
    Seeker.BIRTHDATE,
    Seeker.ISRECIEVEEMAILS,
    Seeker.HIGHESTDEGREE,
    Seeker.ETHNICITY,
    Seeker.GENDER,
    Seeker.ISDISABILITY,
    Seeker.DISABILITY,
    Seeker.CV,
    Seeker.PASSWORD,
    Seeker.PREFFERED_CITY,
    SEEKER.EMAIL,
    SEEKER.JOB_PREFERENCES_ID,
    SCORE(1)
    FROM SEEKER Seeker
    WHERE CONTAINS(CV, '<query>
    <textquery lang="ENGLISH" grammar="context">' ||
    GET_RELATED_CATEGORIES(IN_KEYWORD) ||
    '</textquery>
    <score datatype="INTEGER"/>
    </query>', 1) > 0
    LOOP
    PIPE ROW(R); --Error(38,10): PLS-00382: expression is of wrong type
    END LOOP;
    RETURN;
    END GET_SEEKERS;
    END STAFF_AGENCY_PKG;
    How do I need to amend my user type in order to suffice?
    Oracle Release 11.2.0.1.0
    Many thanks in advance!

    >
    How do I need to amend my user type in order to suffice?
    >
    You will need to create two new TYPEs. One that has all of the columns of the TOSS.SEEKER table and the new SCORE column and then a TYPE that is a table of the first type.
    See the Example 12-22 Using a Pipelined Table Function For a Transformation in the PL/SQl language reference
    http://docs.oracle.com/cd/B28359_01/appdev.111/b28370/tuning.htm#i53120
    Here is the first part
    -- Define the ref cursor types and function
    CREATE OR REPLACE PACKAGE refcur_pkg IS
      TYPE refcur_t IS REF CURSOR RETURN employees%ROWTYPE;
      TYPE outrec_typ IS RECORD (
        var_num    NUMBER(6),
        var_char1  VARCHAR2(30),
        var_char2  VARCHAR2(30));
      TYPE outrecset IS TABLE OF outrec_typ;
    FUNCTION f_trans(p refcur_t)
          RETURN outrecset PIPELINED;
    END refcur_pkg;
    CREATE OR REPLACE PACKAGE BODY refcur_pkg IS
      FUNCTION f_trans(p refcur_t)
       RETURN outrecset PIPELINED IS
        out_rec outrec_typ;
        in_rec  p%ROWTYPE;
      BEGINModify
      TYPE outrec_typ IS RECORD (
        var_num    NUMBER(6),
        var_char1  VARCHAR2(30),
        var_char2  VARCHAR2(30));
      TYPE outrecset IS TABLE OF outrec_typ;to include all of the columns you need. Unfortunately you will have to manually list all of the columns of the TOSS.SEEKER table. If you expect to need this same structure in other places you should create them as SQL types instead of PL/SQL types.
    This example should be enough to show you how to change your code to do something similar.

  • Render a column based on other column value in the same table

    JDev 11.1.1.6.0
    This may be a silly question but I am stuck
    I need to conditionally render a column say A. Condition is like if the value in the other column B of same table is equal to F. I should render column A only when this condition is satisfied. I have tried the following code:
    <af:column sortProperty="PhoneNumber1"
    sortable="false"
    headerText="#{bindings.A.hints.PhoneNumber1.label}"
    id="c146"
    rendered="#{row.PhoneNumber1ResponseFlag eq 'F'}">
    <af:outputText value="#{row.PhoneNumber1}"
    id="ot130"/>
    </af:column>
    <af:column sortProperty="PhoneNumber1ResponseFlag"
    sortable="false"
    headerText="#{bindings.B.hints.PhoneNumber1ResponseFlag.label}"
    id="c80" rendered="true">
    <af:outputText value="#{row.PhoneNumber1ResponseFlag}"
    id="ot129"/>
    </af:column>
    The data shown in the table for column  PhoneNumber1ResponseFlag is F. Still my condition is not working.

    Timo was saying that it is not possible to render the column in some situations and not in anothers, you will always have to render the column.
    The best way to do this is instead of showing a column with the text ' ', show something meaningfull to the user. This is a DataWarehouse advice to you and may be usefull since you're using ADF in a area that uses DataWarehouse..
    So the code could be something like this (based on Timo's code):
    <af:column sortProperty="PhoneNumber1"
    sortable="false"
    headerText="#{bindings.A.hints.PhoneNumber1.label}"
    id="c146">
    <af:outputText value="#{row.PhoneNumber1ResponseFlag eq 'False.' ? row.PhoneNumber1 : 'No value applied.'"
        id="ot130"/>
    </af:column>
    <af:column sortProperty="PhoneNumber1ResponseFlag"
    sortable="false"
    headerText="#{bindings.B.hints.PhoneNumber1ResponseFlag.label}"
    id="c80">
    <af:outputText value="#{row.PhoneNumber1ResponseFlag}"
        id="ot129"/>
    </af:column>
    Hope that helps,
    Frederico.

  • Row/column counter for tables

    Hello,
    I know this is very basic, but so far examples I dug up don't really anything remotely to what I want.
    I have 3 databases. Well they are defined as "connections" in SQLDeveloper I hope that's the same I am still not used to Oracle abstractions.
    Each has several tables. All I want is loop through each of the 3 DBs and log row count and table count.
    Say DB1:
    Rows: Columns:
    Table1: x y
    Table2: x y
    I don't really care what's inside them. I found one example that did it but it listed some system tables that aren't part of my db. Changing "owner" didn't really help.
    From the value of the variable "Owner" means a database, is that correct?
    Oh and I also don't care if the code is "inefficient", tables aren't that big.
    Thanks in advance.
    Edited by: 940349 on Jun 14, 2012 6:22 AM

    not sure what you are planning to achieve, but you can use below query to get owner of table, table name , column name, number of tables by owner and number of column in a table (belonging to owner). This will require access to dba_tab_columns.
    select owner,table_name,count(*) over(partition by owner) count_table,column_name,count(*) over(partition by owner,table_name) count_column from dba_tab_columns;

  • Counting Columns in a Structure or Table?

    HI,
    can any one tell me the best way to count the number of Columns a structure or internal table has.
    Thanks
    C

    Hi,
    Try using the describe field type s_struc components n..
    data: begin of s_struc,
           field1,
           field2,
          end of s_struc.
    data: v_int type int4.
    describe field s_struc type s_struc components v_int.
    write: / v_int.
    Thanks,
    Naren
    Message was edited by: Narendran Muthukumaran

  • Want to flatten my parent-child hierarchy into an level-based hierarchy.

    Hi Expert,
    Can anyone let me know how I can convert my parent-child hierarchy into an LEVEL-based hierarchy.
    Thanks in Advance
    S

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

  • How to count number of child? child.getSize(); ??

    Hi,
    how to count to number of child node?
    something like
    child.getSize()

    Child is page or node ? Unfortunelty both Node and Page API returns Iterator and you have to loop through that to find number of childs. Other option is to use querymanager api and check size of resultset.
    [1] http://dev.day.com/docs/en/cq/current/javadoc/com/day/cq/wcm/api/Page.html
    [2] http://jackrabbit.apache.org/api/1.5/org/apache/jackrabbit/api/jsr283/Node.html
    [3] http://www.day.com/maven/jsr170/javadocs/jcr-1.0/javax/jcr/query/package-summary.html
    Yogesh

  • 919: Column count replaces query count when opening table/view/etc tab

    I don't know whether this is intentional or not, but I have just noticed that opening a table or view tab from the connection pane replaces the existing query count message with the query count from the column query. For example, opening a table tab for a table with 14 columns sets the query count message to "All Rows Fetched: 14".
    This is not a big issue, but adds to the aggravation of only having the latest query count message, rather than one for each SQL Worksheet.
    Is it possible to find somewhere on the SQL Worksheet that we can put it's query count message (for example to the right of the execution time)?

    I am happy for querying the columns of a table/view/etc to display the fetch count of the columns, although I am rarely interested in how many columns there are in a table/view/etc.
    However, I already find it frustrating that the query count is only for the last fetch - it can be very useful having the query count for last fetch per SQL Worksheet. Having the last fetch overwritten by opening a table tab only makes it more frustrating.

  • Define variable a ROWTYPE based on a table name passed as a parameter

    I am trying to write a procedure that processes rows for tables of differing structures. Table_name is passed as an IN parameter to the procedure. I define a cursor within the function that is defined by a SELECT * FROM table_name. I also need to define two variables, l_this_row and l_prev_row. I need to define them as table_name%ROWTYPE. Of course, table_name is a VARCHAR2 that contains the name of a table, whereas Oracle is expecting an actual table name in the declaration. How can I define these variables to make something like the code shown below compile and work properly? I am using Oracle 10gR2.
    DEFINE PROCEDURE foo(table_name IN VARCHAR2) IS
    l_this_row table_name%ROWTYPE;
    l_prev_row table_name%ROWTYPE;
    l_cursor SYSREFCURSOR;
    BEGIN
    OPEN l_cursor FOR
    'SELECT * FROM '
    || table_name
    || ' ORDER BY '
    || get_pk_col_name_for_table(table_name)
    || ', version_num'; --version_num is guaranteed to be a valid column name in every table, although the other column names vary in name, quantity, and type per table.
    LOOP
    FETCH l_cursor INTO l_this_record;
    EXIT WHEN l_cursor%NOTFOUND;
    -- dynamic comparison of l_this_record and l_prev_record and conditional processing based on the comparison occurs here
    l_prev_record := l_this_record;
    END LOOP;
    END;

    Billy  Verreynne  wrote:
    Well, one method is to keep the SQL projection consistent across the number of dynamic SQLs being dealt with. With the projection being consistent, your code does not need to guess what the row structure the column returns.Unfortunately, what I need to compare is almost everything except the primary keys. So one table might contain addresses and another might contain invoice headers. There's no way to get them into the same structure.
    Billy  Verreynne  wrote:
    This approach can also be done in a generic fashion - dealing with an arbitrary number of columns per row. This dynamic structure is more flexible, but also increases the complexity of the code that has to deal with this. For example:
    create or replace type TStrings is table of varchar2(4000);Now SQLs can be created to pass any number of columns to the code to process:
    select TStrings( empid, ename, jobid, date_employed, date_of_birth ) from emp order by empidThe code then uses the Count method of the TStrings type to determine the number of columns passed and processes that.Then the problem becomes having to specify all the column names. I need to figure them out dynamically, as in "SELECT column_name FROM user_tab_cols WHERE column_name NOT IN ('ID', 'PREV_ID', 'NEXT_ID')". It would, of course, be best if I didn't have to populate each array element with an individual SELECT in its own EXECUTE IMMEDIATE statement. That would certainly slow things down. If I were trying to write this using ADO.NET, I could reference something like table_name(row_index).columns(ix) without having to know any of the column names, and I could exclude columns by name using a reference like table_name.columns(column_index).name. (I don't recall the exact syntax, but it is something reasonably close to that.) But PL/SQL doesn't seem to have anything close to this.
    Ideally, I want to get it to where I can do something like this in a private function:
    FOR ix IN 1..TStrings.Count LOOP
       IF this_row(ix) <> last_row(ix) THEN
          RETURN FALSE;
       END IF;
    END LOOP;
    RETURN TRUE;
    Billy  Verreynne  wrote:Last comment. I have to echo what the others said. This is not optimal. Dealing with variant/dynamic structures and processing rows using PL/SQL (in a slow-by-slow fashion) does not scale well. Scalability and performance comes from processing data sets using SQL.I completely understand. I'm a big fan of replacing a lot of code with one SQL statement, but that just won't work for this problem.

  • I want to update the FND_FLEX_VALUES_TL table "DESCRIPTION" Column

    Hi,
    i want to update the description column in Fnd_Flex_Values_Tl Table for a specific value set id, but my question is my client is having two languages AR & US he wants the description of AR in Description of US so help me to update the description column as per the AR language for all accounts.
    select ffv.flex_value_set_id,
    ffv.flex_value_id,
    ffv.flex_value,
    ffvtl.flex_value_id,
    ffvtl.language,
    ffvtl.description
    from fnd_flex_values_copy ffv,
    fnd_flex_values_tl_copy ffvtl
    where ffv.FLEX_VALUE_ID=ffvtl.FLEX_VALUE_ID
    and ffv.flex_value_set_id='1007630'
    order by flex_value,language
    Regards,
    Pasha

    As expected...
    Isn't that message self-explanatory?
    You're updating a child record, and if you're updating the cild_table.parent_id then that parent_id has to exist in the parent_table.
    SQL> create table prnt(a varchar2(10) primary key);
    Table created.
    SQL> create table chld(a varchar2(10), b varchar2(10) references prnt (a));
    Table created.
    SQL> insert into prnt values('Parent 1');
    1 row created.
    SQL> insert into chld values('Child 1','Parent 1');
    1 row created.
    SQL> update chld set b = 'Parent 2';
    update chld set b = 'Parent 2'
    ERROR at line 1:
    ORA-02291: integrity constraint (INFO.SYS_C00311351) violated - parent key not found
    SQL> insert into prnt values('Parent 2');
    1 row created.
    SQL> update chld set b = 'Parent 2';
    1 row updated.

  • Query Help with Parent, Child, Child's Child

    Hi all,
    Need some help with a query.  I'm trying to create a stored procedure that is sort of like a Customer, Order, Order, Details.  In my situation the tables are different but nevertheless, I want to grab all the fields from the  Parent, Child,
    and Childs' Child, where the Parent.ParentID = @Parameter.  I tried this:
    CREATE PROCEDURE [dbo].[spGetCompleteProjectXML]
    @ProjectID int = 0
    AS
    SELECT *,
    (SELECT *,
    (SELECT *
    FROM PageControls
    WHERE (PageControls.ProjectPageID = ProjectPages.ProjectPageID))
    FROM ProjectPages
    WHERE (ProjectPages.ProjectID = @ProjectID))
    FROM Projects
    WHERE (ProjectID = @ProjectID)
    FOR XML AUTO, ELEMENTS
    RETURN 0
    I think I'm close, but it was my best effort.  Could someone help?
    thanks in advance

    Hi TPolo,
    Regarding your description, are you looking for a sample like below?
    CREATE TABLE customer(customerID INT, name VARCHAR(99))
    INSERT INTO customer VALUES(1,'Eric')
    INSERT INTO customer VALUES(2,'Nelson')
    CREATE TABLE orders(orderID INT,customerID INT)
    INSERT INTO orders VALUES(1,1);
    INSERT INTO orders VALUES(2,1)
    INSERT INTO orders VALUES(3,2)
    INSERT INTO orders VALUES(4,2)
    CREATE TABLE orderDetails(orderID INT,item VARCHAR(99))
    INSERT INTO orderDetails VALUES(1,'APPLE1')
    INSERT INTO orderDetails VALUES(1,'BANANA1')
    INSERT INTO orderDetails VALUES(2,'APPLE2')
    INSERT INTO orderDetails VALUES(2,'BANANA2')
    INSERT INTO orderDetails VALUES(3,'APPLE3')
    INSERT INTO orderDetails VALUES(3,'BANANA3')
    INSERT INTO orderDetails VALUES(4,'APPLE4')
    INSERT INTO orderDetails VALUES(4,'BANANA5')
    SELECT customer.customerID,customer.name,
    (SELECT orderId,
    SELECT item FROM orderDetails WHERE orderID=orders.orderID FOR XML AUTO,TYPE,ELEMENTS
    FROM orders Where customerID=customer.customerID FOR XML AUTO,TYPE,ELEMENTS)
    FROM customer WHERE customerID=1
    FOR XML AUTO,ELEMENTS
    DROP TABLE customer,orderDetails,orders
    If you have any feedback on our support, please click
    here.
    Eric Zhang
    TechNet Community Support

Maybe you are looking for

  • Additional field required in QA32 -to assign the inspection lot - Inspector

    Hi. need an additional field in QA32 to allot the Inspection lot generated to the Inspector for the purpose of rating the inspectors by running a report. Also needs to appear  a drawing document number against the respective inspection lot which shou

  • ESS benefits and payment not displaying after support pack update

    Hi All, After the latest HR support pack update ESS benefits and payment not displaying SAP ECC 604 EPH5 SAP_ABA 702 SAP Kernel :  720_EXT_REL Kernel Patch number : 439 Netweaver portal version - 7.30 please help Regards Rahul

  • Why will my 7th generation ipod classic not work in my 2006 VW Passat?

    I equipped my vehicle with the VW iPod connector that was hardwired into my vehicle.  I have used both a 1st Gen iPod video/classic as well as a 4th Gen iPod nano with no issues.  However, the 7th gen iPod classic I recently purchased will not play m

  • HR Implementation

    Hi all, Im currently facing a problem of plenty. That is to say, too much to look at, but dont know where to start. Disclaimer: Possible spoilers ahead. So, a little bit of background before I get into the real issue. Im work in a Real Estate organis

  • SSL in selected areas of portal

    Hi There We have a problem.  Due to our client's requirements, the IE security setting "Do Not save encrypted files to disk" means that users cannot cache encrypted content. We currently have SSL enabled for the whole portal.  This is causing massive