Counting repeating values

I have to record league results and the points against each game and have a total of 84 to record for 15 teams.
I have set it up to record Points, For and Against goals across the page from column C to CH but I have been unable to record the number of times games have been won, lost or drawn.
Is it possible to count each value and have it updated each time Ienter the new results in a new column showing won, lost or drawn?
Any assistance that you can offer will be most appreciated

Here's the code:
I have used a Hashtable to store the value and its number of occurrences. Finally to print the result, I used the toString() method of Hashtable but you can print it in your own way, if u wish.
import java.util.Hashtable;
import java.io.*;
public class Repeating {
     public static void main(String args[]) {
          int[] num = new int[6];
          try {
               BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
               System.out.println("Enter six numbers: (press Enter after each number)");
               for ( int i=0 ; i<num.length ; i++ ) {
                    System.out.print("Enter number #" + i + ": ");
                    num[i] = Integer.parseInt(br.readLine());
               System.out.println("The array is: ");
               for ( int i=0 ; i<num.length ; i++ ) {
                    System.out.print(num[i] + " ");
               System.out.println("");
          } catch (Exception e) {
               System.out.println("Enter only one number in each line ...\n\n");
               e.printStackTrace();
          Hashtable h = new Hashtable();
          for ( int i=0 ; i<num.length ; i++ ) {
               Integer ii = new Integer(num);
               if ( h.containsKey(ii) ) {
                    Integer val = (Integer) h.get(ii);
                    h.put(ii, new Integer(val.intValue() + 1));
               } else {
                    h.put(ii, new Integer(1));
          System.out.println("\nThe result: (value=number of occurrences)");
          System.out.println(h);

Similar Messages

  • Avoid repeating values in details section

    Hi,
    I have a report with a lot of formulas - depending on certain values in a certain Oracle database table values are summed up.
    The fields are therefore placed in the report footer.
    As I now have to insert a grouping I need to move the fields into the details section. However, I don't want to display each value there but only the sum - I would like to avoid repeating values in the details section.
    A formula looks like this:
    stringvar A1;
    if {OUR_TABLE_FIELD} = 1 then A1 := {OTHER_TABLE.OTHER_FIELD}
    Else A1:=A1;
    A1;
    Thanks!

    Add a suitable group and then display data in this group footer, suppress detail section. It will effectively show the last detail line and thus eliminate duplicates from view. However, data is still there so if you want to use summaries you will need to use Running totals to ensure duplicates are not counted/summed
    Ian

  • Count distinct values in report builder

    i have a situation where i have to count distinct number of customers.
    i have a query which returns the list of values of bill_to_customer_id from ra_customer_trx_all table and i have to display only the number of distinct customers. i cant do this in the query because it has to be grouped and i am doing it in an aging report. i have to list the number of distinct customers in each aging period. can anybody please help me how to achieve this in reports 6i.
    thanks

    how can i count distinct values in reports?
    the situation is like this
    i have a query which lists customer_id, invoice number, amount due
    so what i want is to count the distinct customer_id and display the number of distinct customers. one customer_id can be repeated any number of times but i should count it only once.

  • Repeating Values on axis (SSRS Chart)

    Hi ,
         i have repeating values on axis .i am not sure sure how to get rid of this problem.i did workaround like changing interval property expression to iif(max(count(Fileld))<4,1,0) but it didn't help.i have attached  image file
    for reference .

    Hi Zamin,
    From your screenshot, it seems that the interval of the axis is 0.5, and the "Decimal places" was set to 0 in the “Number” tab, right? So 0.5 becomes 1 and 1.5 becomes 2. To avoid this issue, please set the "Decimal places" to 1 in the “Number” tab.
    If you have any questions, please feel free to ask.
    Regards,
    Charlie Liao
    TechNet Community Support

  • Everyone is how to delete repeating values?

    There is a column,values are repeated,everyone is how to delete repeating values?
    Assuming that this set of numerical many, can not directly determine whether there is a duplicate value.
    Thank you~
    Message was edited by: Tao.
    Message was edited by: Tao.

    Hi Tao,
    I've found that a short AppleScript provides a convenient way to identify duplicates (repeating values) in a range.
    Just select the range of cells you want to check for duplicates and click. It will turn the duplicates red.
    --select range, run, turns duplicates red
    tell application "Numbers" to tell front document to tell active sheet
              set selected_table to first table whose class of selection range is range
              tell selected_table
                        set selected_range to the selection range
                        tell selected_range
                                  set values_list to {}
                                  repeat with i from 1 to count cells
                                            set this_value to value of cell i as text
                                            if values_list contains this_value then set text color of cell i to "red"
                                            set end of values_list to this_value
                                  end repeat
                        end tell
              end tell
    end tell
    --end of script
    Just copy and paste the above script into AppleScript Editor, and run it from there. Or place it in your scripts menu. Or download this  Automator Service (Dropbox download) and double-click it to install it in your Services menu.
    Similarly, if you want to get a list of just the distinct values in a range (i.e. with duplicates removed) this Copy Distinct Automator Service (Dropbox download) is very convenient.
    Select the cells, make the menu pick, then paste the distinct values wherever you want in a table by single-clicking a cell and typing command-v to paste.
    These functions become, in essence, a customized menu.  That way you don't have to set up formulas to do this each time you work with a new Numbers document.
    SG

  • Mobile List Bind aggregation - repeated values?

    Hi all, i'm new to SAPui5 so please forgive me if this is already discussed.
    I'm calling a odata service (http://h03zdb.hcc.uni-magdeburg.de:8003/workshop/sessiona/12/Services/msgTab.xsodata/MSGTABLE?$filter=FROM%20eq%20%27STU…) and I get the values stored in a table in json. I want to show this in a list but there are repeated values created for the list. Is it because of bindAggregation?

    Here is the whole code.
    I used split app and added two models for the detail and master page.
    I'm very new to this so sorry for bad coding
    <html>
      <head>
      <meta http-equiv="X-UA-Compatible" content="IE=edge" />
      <title>SRH Chat</title>
      <script src="/sap/ui5/1/resources/sap-ui-core.js"
      id="sap-ui-bootstrap"
      data-sap-ui-libs="sap.m"
      data-sap-ui-theme="sap_bluecrystal">
      </script>
      <!-- only load the mobile lib "sap.m" and the "sap_bluecrystal" theme -->
      <script type="text/javascript">
      var sessionKey = "STUDENT01";
      // Login user to get session id
      var oDetailPage2 = new sap.m.Page("detail2");
      var url = "http://h03zdb.hcc.uni-magdeburg.de:8003/workshop/sessiona/12/Services/msgTab.xsodata/MSGTABLE?$filter=TO%20eq%20%27"+sessionKey+"%27%20&%20FROM%20eq%20%27"+sessionKey+"%27%20&$format=json";
      $.get( url, function(data1) {
      // create JSON model instance
      var oModel = new sap.ui.model.json.JSONModel();
      // set the data for the model
      oModel.setData(data1);
      // set the model to the core
      oMasterPage1.setModel(oModel);
      var contactList = new sap.m.List("newlist2",{
      title : "{FROM}",
      mode: sap.m.ListMode.SingleSelectMaster,
                select: function(oEv) {
      var item = oEv.getParameter("listItem");
      var desc = item.getTitle();
      retrieveMsgs(desc);
      function retrieveMsgs(desc)
      var aurl = "http://h03zdb.hcc.uni-magdeburg.de:8003/workshop/sessiona/12/Services/msgTab.xsodata/MSGTABLE?$filter=FROM%20eq%20%27"+desc+"%27%20&$format=json";
      $.get( aurl, function( data ) {
    // // create JSON model instance
      var oModel1 = new sap.ui.model.json.JSONModel();
    // // set the data for the model
      oModel1.setData(data);
      // set the model to the core
      oDetailPage2.setModel(oModel1);
      var contactList1 = new sap.m.List("newlist");
      var inputField = new sap.m.TextArea();
      var but1 = new sap.m.Button({text: "Send", tap: function(){
      // Send button press functionality
      var msg = inputField.getValue();
      var murl = "http://h03zdb.hcc.uni-magdeburg.de:8003/workshop/sessiona/12/WebContent/InsertMsg.xsjs?from="+desc+"&to="+sessionKey+"&msg="+msg;
      $.ajax({
            url: murl,
            type: 'POST',
            async: false,
            timeout: 30000,
            success : function (data2){
            var empty = "";
            inputField.setValue(empty);    // clear text area
      //Populate the List with Data from the Model (Set in the Controller of this View)
      contactList1.bindAggregation("items", {
      path : "/d/results", //Reference to the JSON structure
      template: new sap.m.StandardListItem({
      title: "{FROM}", //Refer the name field in the JSON data
      description: "{MSG}", //Address Field in the data
      type: sap.m.ListType.Navigation //Specify what to do while clicking/tapping an item in the list, in this example navigate to another view
      oDetailPage2.addContent(contactList1);
      oDetailPage2.addContent(inputField);
      oDetailPage2.addContent(but1);
      oSplitApp.to("detail2");
      //Populate the List with Data from the Model (Set in the Controller of this View)
      //oModel.createBindingContext("/d/results", null, {select: "FROM"},function(a){});
      contactList.bindAggregation("items", {
      path : "/d/results", //Reference to the JSON structure
      template: new sap.m.StandardListItem({
      title: "{FROM}", //Refer the name field in the JSON data
      //description: "{FROM}", //Address Field in the data
      //select: "FROM,TO",
      type: sap.m.ListType.Navigation //Specify what to do while clicking/tapping an item in the list, in this example navigate to another view
      var oMasterPage1 = new sap.m.Page("master1",{
        title : "Master"
      // adding the list to master
      oMasterPage1.addContent(contactList);
    // //add the master pages to the splitapp control
      oSplitApp.addMasterPage(oMasterPage1);
    //   .addMasterPage(oMasterPage1);
      //add the detail pages to the splitapp control
      oSplitApp.addDetailPage(oDetailPage2);
      //oSplitApp.setInitialDetail("detail");
      //oSplitApp.setInitialMaster("master");
      oSplitApp.placeAt("body");
      </script>
      </head>
      <body class="body">
      <div id="body">
      </div>
      </body>
    </html>

  • Display only first value of the repeated values  in ALV report

    Hi,
    Test Data
    Doc No   Net Val   billing Doc value Qty
    1000      2000.00    567850.00
    1000      2000.00    567850.00
    1000      2000.00    567850.00
    2000      6000.00    767850.00
    In this type of ALV Report in which only the First field value of the repeated value  should be displayed.
    Doc No   Net Val   billing Doc value Qty
    1000      2000.00    567850.00
    2000      6000.00    767850.00
    I can display document value as like expected result in SORT ORDER in LAYOUT but the Quantity value,Net value  which cannot be done in SORT ORDER in LAYOUT.
    Please tell me the suitable solution.

    For a Sales Order there are two Invoice.
    Sales doc     Invoice No    Billed Qty    Net value                     Qtywith  material no
    5000              900             234774.00    456.00000                 65             123
                                             234774.00    456.00000                 25             456
                                             234774.00    456.00000                 35             898
                                             234774.00    456.00000                 20             496
                          901            634774.00    256.00000                 50               746
                                            634774.00    256.00000                 10               456
                                            634774.00    256.00000                 20               545
                                            634774.00    256.00000                 30               869
    I  need to print this billed Qty and Net value  only once in first line and it should not be deleted.
    I need the result like this
    Sales doc     Invoice No    Billed Qty    Net value                     Qtywith          material no
    5000              900             234774.00    456.00000                 65                     123
                                                                                    25                     456
                                                                                    35                     898
                                                                                    20                     496
    5001              901            634774.00    256.00000                 50                       746
                                                                                    10                       456
                                                                                    20                       545
                                                                                    30                       869               
    The same value should not be repeated for Billed Qty and Net Value.
    I can do that for Sales doc in sort order in layout but i couldn't do for Billed qty and Net Value.
    Please  help.

  • ALV: How do I suppress repeating values and page breaks on printed output?

    Good day, everyone!
    First, I've done a LOT of searching trying to find the answer to my question, but I'm not finding an answer.  If this has already been answered and you can point me to a URL, I would appreciate it.
    Here's my issue:  I have a rather simple ALV report.  It has the columns of Person ID, Personnel Number, For Period, In Period, and Amount.  I sort by Person ID and Personnel Number, and if the value repeats on the next line of the report, I want to suppress it (make it blank).
    I thought the answer was in the following code, where I set the GROUP attribute to asterisk:
      CLEAR sortcat_ln.
      sortcat_ln-spos      = '1'.
      sortcat_ln-fieldname = 'PERSONID_EXT'.
      sortcat_ln-up        = c_true.
      sortcat_ln-group     = '*'.
      APPEND sortcat_ln TO sortcat.
      CLEAR sortcat_ln.
      sortcat_ln-spos      = '2'.
      sortcat_ln-fieldname = 'PERNR'.
      sortcat_ln-up        = c_true.
      sortcat_ln-group     = '*'.
      APPEND sortcat_ln TO sortcat.
    It looks PERFECT on the screen -- the values are suppressed if they repeat, and everything appears together on one screen.  However, when I print the report, two things happen:  1) The values repeat on each row, even if they are the same, and 2) I get a page break after each Person ID / Personnel Number combination.
    I now realize that I can't use the GROUP attribute.  Is there some other way in ALV to blank these repeating values and keep all the rows together on one page, rather than page breaking after each value change?
    Thanks!
    Dave

    Hi
    Same requirement i had before, when i try to print preview. the output of the grid display is in grouping is ok, but when i print preview or print it doesnt cater the grouping and page breaks, so what i did i modify the internal table use in alv , after hitting the print preview/print with the format desired by the user. you can do that in user-command. see code below
    FORM user_command USING r_ucomm TYPE syucomm
                            rs_selfield TYPE slis_selfield.
      DATA lt_sort TYPE lvc_t_sort.
      CASE r_ucomm.
        WHEN '&RNT_PREV' OR '&RNT'.
          t_final_x[] = t_final[].
          PERFORM clear_redundant.
          PERFORM set_sort_criteria USING lt_sort.
        WHEN '&F03' OR '&PRINT_BACK_PREVIEW'.
          t_final[] = t_final_x[].
        WHEN OTHERS.
      ENDCASE.
    ENDFORM.                    "user_command
    hope it helps

  • No repeated values and in ascendant sort

    Hi all,
    I'm trying to put this:
    SELECT DISTINCT month FROM Concert ORDER BY month ASC;
    (no repeated values and in ascendant sort) into EJB-QL. This is what I've worked out:
    SELECT DISTINCT OBJECT(o)
    FROM Concert AS o
    ORDER BY o.month ASC
    (month is a field in the bean )
    But this (and several tries later) doesn't work.
    What's wrong with it??
    The query is for a findAll method -without- input parameters which returns a collection, is here the error??? If so, how can I solve it?
    I'm totally lost and frustrated, I'd really appreciate some light
    Thanks a lot in advance

    Your query is currect if table name and attribute name are currect.
    Can you write what type of error is comming?

  • Count all values with a special WHERE clause in a select for a group?

    Hello,
    I have the following table1:
    code, month, value
    *1,1,40*
    *1,2,50*
    *1,3,0*
    *1,4,0*
    *1,5,20*
    *1,6,30*
    *1,7,30*
    *1,8,30*
    *1,9,20*
    *1,10,20*
    *1,11,0*
    *1,12,0*
    *2,1,10*
    *2,2,10*
    *2,3,20*
    *2,4,20*
    *2,5,20*
    *2,6,30*
    *2,7,40*
    *2,8,50*
    *2,9,20*
    *2,10,20*
    *2,11,20*
    *2,12,20*
    This is a table with 3 columns, first column is a code, second one is the number of month, third one is a value.
    Now I want to select the records for each code. For example all records for code=1.
    I want to count how much values=0 for this code=1. After this counting I want to update the value with this count of 0.
    For my example:
    For code 1 there are 4 fields with value 0. Therefore I want to update all values of code1 to 4.
    For the second code=2 there are no value=0. Therefore I want to update the values of code2 to 0.
    This should be the result:
    code, month, value
    *1,1,4*
    *1,2,4*
    *1,3,4*
    *1,4,4*
    *1,5,4*
    *1,6,4*
    *1,7,4*
    *1,8,4*
    *1,9,4*
    *1,10,4*
    *1,11,4*
    *1,12,4*
    *2,1,0*
    *2,2,0*
    *2,3,0*
    *2,4,0*
    *2,5,0*
    *2,6,0*
    *2,7,0*
    *2,8,0*
    *2,9,0*
    *2,10,0*
    *2,11,0*
    *2,12,0*
    My question is:
    Is there any possibility in oracle to count in a select (or in a insert/update statement) all values=0 for one group (in this example named CODE) and do an update in the same statement for this group?
    Hope anyone can give me a hint if this is possible?
    Thanks a lot.
    Best regards,
    Tim

    Here's the select:
    SQL> select code, month
      2        ,count(decode(value,0,1,null)) over (partition by code) ct
      3  from   t
      4  order by code, month
      5  ;
                    CODE                MONTH                   CT
                       1                    1                    4
                       1                    2                    4
                       1                    3                    4
                       1                    4                    4
                       1                    5                    4
                       1                    6                    4
                       1                    7                    4
                       1                    8                    4
                       1                    9                    4
                       1                   10                    4
                       1                   11                    4
                       1                   12                    4
                       2                    1                    0
                       2                    2                    0
                       2                    3                    0
                       2                    4                    0
                       2                    5                    0
                       2                    6                    0
                       2                    7                    0
                       2                    8                    0
                       2                    9                    0
                       2                   10                    0
                       2                   11                    0
                       2                   12                    0

  • Display Repeated Values in a Crosstab - Design Studio 1.2

    I've a report in Design Studio from a Bex query. There are repeated values in few columns which Design Studio 1.2 refuses to display.
    note: I've already unchecked the box "Hide Repeated Key Values" in the query properties of Bex query designer and i'm able to see repeated values when I open the query in Bex analyzer.
    Design studio would not display the repeated values in the crosstab.
    Anyone encountered and fixed a similar issue before?

    Hi Stephen,
    I was not able to resolve this issue, and I had to go ahead with values not being repeated.
    I think this is a limitation of Design Studio with no fix for it in v 1.3 either, unless someone could suggest otherwise.
    Regards,
    Abbas

  • I have SSRS parametarized report in that one data set have repeated values with query parameter . but while am mapping that query parameter to report parameter i need to pass distinct values. How can i resolve this

    I have SSRS parametarized report in that one data set have repeated values with query parameter . but while am mapping that query
    parameter to report parameter i need to pass distinct values. How can i resolve this

    Hi nancharaiah,
    If I understand correctly, you want to pass distinct values to report parameter. In Reporting Service, there are only three methods for parameter's Available Values:
    None
    Specify values
    Get values from a query
    If we utilize the third option that get values from a dataset query, then the all available values are from the returns of the dataset. So if we want to pass distinct values from a dataset, we need to make the dataset returns distinct values. The following
    sample is for your reference:
    Select distinct field_name  from table_name
    If you have any other questions, please feel free to ask.
    Thanks,
    Katherine Xiong
    Katherine Xiong
    TechNet Community Support

  • Objects within an Object - different count of values

    Hi all,
    I have a problem for which I am unable to build a logic and I would appreciate any inputs...
    The objects are as below
    CREATE TYPE num_ids IS TABLE OF NUMBER;
    CREATE TYPE test_rec AS OBJECT
    data   NUMBER(4)
    CREATE TYPE test_tbl AS TABLE OF test_rec;
    CREATE TYPE final_rec AS OBJECT
    data_obj     test_tbl;
    num_tbl      num_ids
    CREATE TYPE final_tbl AS TABLE OF final_rec;
    CREATE TABLE data_num
    data       NUMBER(4),
    subdata  NUMBER
    );Now the problem that I am facing...
    final_tbl is going to have only 1 record and never more than that. I need to populate the table data_num with this record. But since the object final_rec itself is comprised of objects, the count of values in final_tbl.data_obj and final_tbl.num_tbl will always differ.
    I am not able to get the logic to write the loop (?) to populate the data from final_tbl into data_num and would appreciate if anyone could help me out with this...
    Thanks in advance..
    P.S. - Do excuse me if the heading is a little misleading...was not sure what to give as the heading for it to be more meaningful.
    Message was edited by:
    henryswift

    Not sure, but maybe this gives you a hint:
    SQL> create type num_ids is table of number;
    Type created.
    SQL> create type test_rec as object (
       data   number (4)
    Type created.
    SQL> create type test_tbl as table of test_rec;
    Type created.
    SQL> create type final_rec as object (
       data_obj   test_tbl,
       num_tbl    num_ids
    Type created.
    SQL> create type final_tbl as table of final_rec;
    Type created.
    SQL> create table data_num(data       number(4),subdata  number)
    Table created.
    SQL> /* insert into data_num */ select data, column_value
      from table (final_tbl (final_rec (test_tbl (test_rec (1), test_rec (2)),
                                        (num_ids (5, 6, 7)
                 ) t,
           table (t.data_obj), table (t.num_tbl)
          DATA COLUMN_VALUE
             1            5
             1            6
             1            7
             2            5
             2            6
             2            7

  • Web Report - Hide Repeated Values

    My web report hides repeated values regardless of the query setting. 
    Is there any way to set a specific column to not hide repeated values?  Using the table API?
    Thanks!

    dear Kenneth,
    have you try to remove the check mark of properties 'suppress repeated text' in 'specific' section of your web item 'table' in web template ?
    or you can give parameter SUPPRESS_REPETITION_TEXTS for web item 'table' with value blank
    <param name='SUPPRESS_REPETITION_TEXTS' value=' '>
    doc may useful
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/13dc9190-0201-0010-71a4-a9f56cdfcc72
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/b1089290-0201-0010-288c-98e4d26487ee
    hope this helps.

  • XMLAGG repeating values

    Hello, I've just started working with xml and am trying to merge 2 xml documents into a single document.
    The XmlAgg query is repeating the some of the data from the first xmltable.
    I've created a small example of what I am trying to do (is very basic example)
                Select  XMLELEMENT("Questionaire",
                          Xmlagg(
                            XMLELEMENT("Questions",
                              Xmlconcat(
                                Xmlforest(Question_Nbr As "QuestionNumber"
                                        , Question_Type As "QuestionType"
                                        , Question_Asked As "QuestionAsked")
                                        , Xmlelement("QuestionAnswer",Question_Ans)
                                       ))Order By Id)) QT
                From (Select Qt.Id, Qa.Question_Nbr, Qt.Question_Type, Qt.Question_Asked, Qa.Question_Ans
                      From Xmltable ('/Test/Questions/question' Passing Xmltype('<Test><Questions><question><type>general</type><asked>Are you ok</asked></question><question><type>specific</type><asked>Do you know why not working</asked></question></Questions></Test>')
                              COLUMNS
                                  Id For Ordinality
                                , Question_Type Varchar2(100) Path 'type'
                                , Question_Asked varchar2(100) path 'asked') Qt
                      inner join   XMLTABLE ('/Results/question' PASSING XMLTYPE('<Results><question><nbr>1</nbr><ans>Yes</ans></question><question><nbr>2</nbr><ans>No</ans></question></Results>')
                              COLUMNS
                                  Id For Ordinality
                                , Question_Nbr Number Path 'nbr'
                                , Question_Ans varchar2(100) path 'ans') Qa
                      ON Qt.Id = Qa.Id);produces the following: QuestionNumber is 2 in both Questions/QuestionNumber (more nodes = more repeated values)
    <Questionaire>
      <Questions>
        <QuestionNumber>2</QuestionNumber>
        <QuestionType>general</QuestionType>
        <QuestionAsked>Are you ok</QuestionAsked>
        <QuestionAnswer>Yes</QuestionAnswer>
      </Questions>
      <Questions>
        <QuestionNumber>2</QuestionNumber>
        <QuestionType>specific</QuestionType>
        <QuestionAsked>Do you know why not working</QuestionAsked>
        <QuestionAnswer>No</QuestionAnswer>
      </Questions>
    </Questionaire>Running the inner query produces 2 rows with the correct data.
    Select Qt.Id, Qa.Question_Nbr, Qt.Question_Type, Qt.Question_Asked, Qa.Question_Ans
                      From Xmltable ('/Test/Questions/question' Passing Xmltype('<Test><Questions><question><type>general</type><asked>Are you ok</asked></question><question><type>specific</type><asked>Do you know why not working</asked></question></Questions></Test>')
                              COLUMNS
                                  Id For Ordinality
                                , Question_Type Varchar2(100) Path 'type'
                                , Question_Asked varchar2(100) path 'asked') Qt
                      inner join   XMLTABLE ('/Results/question' PASSING XMLTYPE('<Results><question><nbr>1</nbr><ans>Yes</ans></question><question><nbr>2</nbr><ans>No</ans></question></Results>')
                              COLUMNS
                                  Id For Ordinality
                                , Question_Nbr Number Path 'nbr'
                                , Question_Ans varchar2(100) path 'ans') Qa
                      ON Qt.Id = Qa.IdQUESTION_NBR | QUESTION_TYPE | QUESTION_ASKED | QUESTION_ANS
    1 | general | Are you ok | Yes
    2 | specific | Do you know why not working | no
    database version:
    Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production
    PL/SQL Release 11.1.0.7.0 - Production
    "CORE     11.1.0.7.0     Production"
    TNS for Linux: Version 11.1.0.7.0 - Production
    NLSRTL Version 11.1.0.7.0 - Production
    Can anyone point out where my query has gone wrong.
    Thanks
    Mike.

    Hi Mike,
    Your query is OK and I don't reproduce on versions 10.2.0.5 and 11.2.0.2, so unless you're not telling us everything it must be a bug in your version.
    I'm just stabbing in the dark but try removing XMLConcat, you don't need it here :
    Select XMLELEMENT("Questionaire",
             Xmlagg(
               XMLELEMENT("Questions",
                 Xmlforest(Question_Nbr As "QuestionNumber"
                         , Question_Type As "QuestionType"
                         , Question_Asked As "QuestionAsked"
                         , Question_Ans as "QuestionAnswer")
                ) Order By Id
            ) QT
    From (
    ...Alternatively, a single XQuery should do the job too :
    SQL> SELECT XMLSerialize(document qt as clob indent) qt
      2  FROM XMLTable(
      3  '<Questionaire>
      4   {
      5     for $i at $qn in $qst/Test/Questions/question
      6       , $j at $rn in $res/Results/question
      7     where $rn = $qn
      8     return element Questions {
      9       element QuestionNumber {data($j/nbr)}
    10     , element QuestionType   {data($i/type)}
    11     , element QuestionAsked  {data($i/asked)}
    12     , element QuestionAnswer {data($j/ans)}
    13     }
    14   }
    15   </Questionaire>'
    16    passing xmltype('<Test>
    17   <Questions>
    18    <question><type>general</type><asked>Are you ok</asked></question>
    19    <question><type>specific</type><asked>Do you know why not working</asked></question>
    20   </Questions>
    21  </Test>') as "qst"
    22  , xmltype('<Results>
    23   <question><nbr>1</nbr><ans>Yes</ans></question>
    24   <question><nbr>2</nbr><ans>No</ans></question>
    25  </Results>') as "res"
    26  columns qt xmltype path '.'
    27  );
    QT
    <Questionaire>
      <Questions>
        <QuestionNumber>1</QuestionNumber>
        <QuestionType>general</QuestionType>
        <QuestionAsked>Are you ok</QuestionAsked>
        <QuestionAnswer>Yes</QuestionAnswer>
      </Questions>
      <Questions>
        <QuestionNumber>2</QuestionNumber>
        <QuestionType>specific</QuestionType>
        <QuestionAsked>Do you know why not working</QuestionAsked>
        <QuestionAnswer>No</QuestionAnswer>
      </Questions>
    </Questionaire>

Maybe you are looking for