Using GROUP BY Doubt

Eg: i have an employees table
With CURADDRIND 0's and 1's and CREATEDATE is a DATE Column
i want to query and get the Latest CURRADDRIND for a particular employee for the maximum of CREATE DATE
I Have data like this
empid curraddrind createdte
130 0 9/10/2008
130 1 9/15/2008
130 0 8/15/2008
i want output
1 9/15/2008
i wrote query like this
select curraddrind,max(createdte) from emp
where empid=130
group by curraddrind
i am getting
1 9/15/2008
0 9/10/2008-->this also ..but shud be omitted
can anyone give solution for this ..
Thanks in advance

Or using only one table access:
SQL> create table t (empid,curraddrind,createdte)
  2  as
  3  select 130, 0, date '2008-09-10' from dual union all
  4  select 130, 1, date '2008-09-15' from dual union all
  5  select 130, 0, date '2008-08-15' from dual
  6  /
Table created.
SQL> select max(curraddrind) keep (dense_rank last order by createdte) curraddrind
  2       , max(createdte) createdte
  3    from t
  4   where empid = 130
  5  /
CURRADDRIND CREATEDTE
          1 15-09-2008 00:00:00
1 row selected.Regards,
Rob.

Similar Messages

  • Mandatory fields while using Group chart of accounts

    Hi,
    Which are the mandatory fields while maintaining GL accounts in FS00 if i am using Group chart of accounts.
    And how attached these group chart of accounts gl to the operational chart of account GL.
    raj

    Hi,
    the assignment from operational chart of accounts to group chart of accounts is done in OB13. Follow the steps in Customizing IMG FIn. Acc. (new) / Consolidation preparation (new) / General specifications / G/L and FS Charts of accounts...
    Best regards, Christian

  • Using Groups in SharePoint from Active Directory

    Hello,
    Is it possible to use groups in SharePoint from AD?
    I have several groups in AD that I would like to use in SP. Of course SP has its own set up groups in permission (Owner, Member and Visitor). I do not want to use these groups. What I would like to do is use groups that are in my AD and assign those the
    designer, contributor, read-only..etc permission.
    For example, SP people picker finds my AD group called "Finance_Project" and assign this group with permission rights as a contributor.
    Is this doable in SharePoint. I would think since SharePoint can be authenticated with AD, you should be able to use your own AD groups.
    Any suggestions, articles and answers are greatly appreciated.
    artisticweb

    You can do this in SharePoint. are you importing the AD groups via UPA?
    Creating a SharePoint group and adding an Active Directory group to its members…this allows anyone in the Active Directory group to participate in the SharePoint group
    Mapping roles directly to Active Directory groups and not using SharePoint groups at all.
    here is couple of article which will explain your choices one over to other
    Assign permission levels in SharePoint 2013
    Using Active Directory Vs. SharePoint Groups
    http://sergeluca.wordpress.com/2013/07/06/sharepoint-2013-use-ag-groups-yes-butdont-forget-the-security-token-caching-logontokencacheexpirationwindow-and-windowstokenlifetime/
    Please remember to mark your question as answered &Vote helpful,if this solves/helps your problem. ****************************************************************************************** Thanks -WS MCITP(SharePoint 2010, 2013) Blog: http://wscheema.com/blog

  • How to write a SQL Query without using group by clause

    Hi,
    Can anyone help me to find out if there is a approach to build a SQL Query without using group by clause.
    Please site an example if is it so,
    Regards

    I hope this example could illuminate danepc on is problem.
    CREATE or replace TYPE MY_ARRAY AS TABLE OF INTEGER
    CREATE OR REPLACE FUNCTION GET_ARR return my_array
    as
         arr my_array;
    begin
         arr := my_array();
         for i in 1..10 loop
              arr.extend;
              arr(i) := i mod 7;
         end loop;
         return arr;
    end;
    select column_value
    from table(get_arr)
    order by column_value;
    select column_value,count(*) occurences
    from table(get_arr)
    group by column_value
    order by column_value;And the output should be something like this:
    SQL> CREATE or replace TYPE MY_ARRAY AS TABLE OF INTEGER
      2  /
    Tipo creato.
    SQL>
    SQL> CREATE OR REPLACE FUNCTION GET_ARR return my_array
      2  as
      3   arr my_array;
      4  begin
      5   arr := my_array();
      6   for i in 1..10 loop
      7    arr.extend;
      8    arr(i) := i mod 7;
      9   end loop;
    10   return arr;
    11  end;
    12  /
    Funzione creata.
    SQL>
    SQL>
    SQL> select column_value
      2  from table(get_arr)
      3  order by column_value;
    COLUMN_VALUE
               0
               1
               1
               2
               2
               3
               3
               4
               5
               6
    Selezionate 10 righe.
    SQL>
    SQL> select column_value,count(*) occurences
      2  from table(get_arr)
      3  group by column_value
      4  order by column_value;
    COLUMN_VALUE OCCURENCES
               0          1
               1          2
               2          2
               3          2
               4          1
               5          1
               6          1
    Selezionate 7 righe.
    SQL> Bye Alessandro

  • How can I send a message to multiple contacts using "groups".

    How can I send a message to multiple contacts using "groups".
    It was easy on my sony ericssonn....do i need to download an app?

    There is no group send option like you are looking for.
    To send to a group you have to pick each person you want to send to and send as a group that way. Then don't delete that SMS thread and you can reuse it again later.
    As for an app, well SMS works via your carrier and the OS, not something an App can do unless the app send the data to them (a third party) and then they relay it to the carrier. Do you really want to be sending your SMS to some 3rd party first?

  • Error while using Group By on 2 Querys joined by union

    Hello Everyone
    I have a situation where in one report i cannot group the data and in another report when i group the data i am unable to view subject area.
    I Had a Complex Request from my client , i have to claculate a report based on 2 dimensions i.e i am calculating 2 measures from one dimension and other 3 measures from other dimension and then using UNION to join both the querys , for the same description the data is being displayed in 2 rows , then i i tried to combine both the querys from union and trying to select from those then i am getting the result and the problem is i am unable to access the subject area , its giving "Either you do not have permission to use the subject area within Answers, or the subject area does not exist." Error , i am unable to add prompts to these request
    I want the investor Grants Row to be displayed in one Column , I am already using Group by in one of the querys.
    Study                      Cost            Approved         Committed                 Earned          Paid Balance
    Investigator Grants 350,000.00 113,770.78 0.00 0.00 0.00
    Investigator Grants 350,000.00 113,770.78 42,403.13 19,905.90 22,497.23
    Labs 23,000.00 0.00 0.00 0.00 0.00
    Study Drug 47,000.00 0.00 0.00 0.00 0.00
    Other 0.00 0.00 0.00 0.00 0.00
    Here is my query
    SELECT "- Protocol"."Protocol #" saw_0, "- Protocol"."Working Title" saw_1, CURRENT_DATE saw_2, "- Administration"."Display Currency Code" saw_3, "- Protocol"."Managing Country" saw_4, "- Protocol".Country saw_5, "- Protocol"."Country OPS" saw_6, "- Protocol"."EU Country" saw_7, "- Protocol"."GCO Region" saw_8, "- Protocol"."GPB Region" saw_9, "- Administration"."Study Cost" saw_10, SUM (IfNull("- Budget and Payment Facts"."Protocol Cost Line Item Amount - Display CCY",0) BY "- Administration"."Study Cost" ) saw_11, SUM(IfNull("- Budget and Payment Facts"."Committed Amount - Display CCY",0) BY "- Administration"."Study Cost") saw_12, SUM(IfNull("- Budget and Payment Facts"."Actual Amount - Display CCY",0) BY "- Administration"."Study Cost") saw_13, SUM(IfNull("- Budget and Payment Facts"."Amount Paid (SP) - Display CCY",0) BY "- Administration"."Study Cost") saw_14, SUM(IfNull("- Budget and Payment Facts"."Actual Amount - Display CCY",0)-IfNull("- Budget and Payment Facts"."Amount Paid (SP) - Display CCY",0) BY "- Administration"."Study Cost") saw_15, CASE WHEN "- Administration"."Study Cost" = 'Other' THEN 1 END saw_16 FROM "SPECTRUM Reporting" WHERE ("- Administration"."Display Currency Code" = 'USD') AND ("- Protocol"."Protocol #" = 'P31248') UNION SELECT "- Protocol"."Protocol #" saw_0, "- Protocol"."Working Title" saw_1, CURRENT_DATE saw_2, "- Administration". "Display Currency Code" saw_3, "- Protocol"."Managing Country" saw_4, "- Protocol".Country saw_5, "- Protocol"."Country OPS" saw_6, "- Protocol"."EU Country" saw_7, "- Protocol"."GCO Region" saw_8, "- Protocol"."GPB Region" saw_9, "- Administration"."Study Cost" saw_10, IfNull("- Budget and Payment Facts"."Protocol Cost Line Item Amount - Display CCY",0) saw_11, IfNull("- Budget and Payment Facts"."Committed Amount - Display CCY",0) saw_12, 0.00 saw_13, 0.00 saw_14, 0.00 saw_15, CASE WHEN "- Administration"."Study Cost" = 'Other' THEN 1 END saw_16 FROM "SPECTRUM Reporting" WHERE ("- Protocol"."Protocol #" = 'P31248') AND ("- Administration". "Display Currency Code" = 'USD') ORDER BY saw_16 DESC
    Any help is appreciated ..!
    ~Srix

    Here is the query i used to group the data but i cannot access Answers with this query
    SELECT saw_0 saw_0, saw_1 saw_1, saw_2 saw_2, saw_3 saw_3, saw_4 saw_4, saw_5 saw_5, saw_6 saw_6, saw_7 saw_7, saw_8 saw_8, saw_9 saw_9, saw_10 saw_10, SUM(saw_11 BY saw_10) saw_11, SUM(saw_12 BY saw_10 ) saw_12, SUM(saw_13 BY saw_10) saw_13, SUM(saw_14 BY saw_10) saw_14, SUM(saw_15 BY saw_10) saw_15, saw_16 saw_16 FROM (SELECT "- Protocol"."Protocol #" saw_0, "- Protocol"."Working Title" saw_1, CURRENT_DATE saw_2, "- Administration"."Display Currency Code" saw_3, "- Protocol"."Managing Country" saw_4, "- Protocol".Country saw_5, "- Protocol"."Country OPS" saw_6, "- Protocol"."EU Country" saw_7, "- Protocol"."GCO Region" saw_8, "- Protocol"."GPB Region" saw_9, "- Administration"."Study Cost" saw_10, SUM (IfNull("- Budget and Payment Facts"."Protocol Cost Line Item Amount - Display CCY",0) BY "- Administration"."Study Cost" ) saw_11, SUM(IfNull("- Budget and Payment Facts"."Committed Amount - Display CCY",0) BY "- Administration"."Study Cost") saw_12, SUM(IfNull("- Budget and Payment Facts"."Actual Amount - Display CCY",0) BY "- Administration"."Study Cost") saw_13, SUM(IfNull("- Budget and Payment Facts"."Amount Paid (SP) - Display CCY",0) BY "- Administration"."Study Cost") saw_14, SUM(IfNull("- Budget and Payment Facts"."Actual Amount - Display CCY",0)-IfNull("- Budget and Payment Facts"."Amount Paid (SP) - Display CCY",0) BY "- Administration"."Study Cost") saw_15, CASE WHEN "- Administration"."Study Cost" = 'Other' THEN 1 END saw_16 FROM "SPECTRUM Reporting" WHERE ("- Administration"."Display Currency Code" = 'USD') AND ("- Protocol"."Protocol #" = 'P31248') AND ("- Payment"."Payment Number"="- Payment"."Related Payment Request Number")
    UNION SELECT "- Protocol"."Protocol #" saw_0, "- Protocol"."Working Title" saw_1, CURRENT_DATE saw_2, "- Administration". "Display Currency Code" saw_3, "- Protocol"."Managing Country" saw_4, "- Protocol".Country saw_5, "- Protocol"."Country OPS" saw_6, "- Protocol"."EU Country" saw_7, "- Protocol"."GCO Region" saw_8, "- Protocol"."GPB Region" saw_9, "- Administration"."Study Cost" saw_10, IfNull("- Budget and Payment Facts"."Protocol Cost Line Item Amount - Display CCY",0) saw_11, IfNull("- Budget and Payment Facts"."Committed Amount - Display CCY",0) saw_12, 0.00 saw_13, 0.00 saw_14, 0.00 saw_15, CASE WHEN "- Administration"."Study Cost" = 'Other' THEN 1 END saw_16 FROM "SPECTRUM Reporting" WHERE ("- Administration"."Display Currency Code" = 'USD') AND ("- Protocol"."Protocol #" = 'P31248')) T GROUP BY saw_0, saw_1, saw_2, saw_3, saw_4, saw_5, saw_6, saw_7, saw_8, saw_9, saw_10 , saw_11, saw_12, saw_13, saw_14, saw_15, saw_16 ORDER BY saw_0, saw_1, saw_2, saw_3, saw_4, saw_5, saw_6

  • Isse with using Grouping Sets in SQL Server 2008 R2

    Hi,
    I created a query in SQL Server 2012 using grouping sets that works fine.  When I try to use the same query in SQL Server 2008 I get an error ("Inccorrect syntax near SETS").
    I researched using grouping sets in 2008 and didn't see any issue with my query.  What is different in grouping sets 2008 vs 2012?
    SELECT tl.ClientRegionCd as [Client Region Code] , tl.ClientRegionDesc as [Region Name], count(tl.CompleteICN) as [Trauma Letters Sent]
    from TORT_Trauma_Letters tl
    Where CONVERT(VARCHAR(26), tl.SecondNoticeSent, 23) between '2014-06-12' and '2014-06-12'
    GROUP BY GROUPING SETS((tl.ClientRegionCd, tl.ClientRegionDesc), ())
    Stacie

    Check this blog post as how to deal with date ranges
    http://sqlblog.com/blogs/aaron_bertrand/archive/2009/10/16/bad-habits-to-kick-mishandling-date-range-queries.aspx
    For your result you can simply achieve your result with UNION ALL, e.g.
    select Client, Region, Letters
    from myTable 
    UNION ALL
    select NULL, NULL, SUM(letters) as Letters
    For every expert, there is an equal and opposite expert. - Becker's Law
    My blog
    My TechNet articles

  • Error while using group function

    Oracle forms6i
    Hai
    While i am compile my coding it compile successfully, but when i tried to executes i shows error in group function
    my coding is
    if (cnt<>0 ) then
    select BARCODE,INTIME,OUTTIME into today_bar,today_in,today_out from dail_att where BARCODE= :Barcode
    and ATTEND_DATE = :bardate;
    update dail_att set outtime = max(:bartime) where barcode= :barcode
    and ATTEND_DATE = :bardate;
    else
    if (cnt2<>0 ) then
    select INTIME,OUTTIME into yest_in,yest_out from dail_att where BARCODE= :Barcode
    and ATTEND_DATE = :bardate-1;
    if(yest_in is not null and yest_out is null) then
    update dail_att set outtime =max(:bartime) where barcode= :barcode
    and ATTEND_DATE = :bardate-1;
    else
    insert into dail_att(barcode,intime,attend_date)
    values(:barcode,min(:bartime),:bardate);
    end if;
    else
    if :bartime between 0100 and 0630 then
    insert into dail_att(barcode,intime,attend_date)
    values(:barcode,min(:bartime),:bardate-1);
    update dail_att set outtime = max(:bartime) where barcode= :barcode
    and ATTEND_DATE = :bardate-1;
    else
    insert into dail_att(barcode,intime,attend_date)
    values(:barcode,:min(bartime),:bardate);
    end if;     
    end if;
    end if;
    while i am trying to this groupfunction it throws error while i use having tell me how to use group function and where
    to use
    Regadrs
    Srikkanth.M

    Hai sir
    I had a table that contain fields
    EMPCODE NUMBER
    EMPNAME VARCHAR2(25)
    BARCODE VARCHAR2(25)
    INTIME VARCHAR2(25)
    OUTTIME VARCHAR2(25)
    INTRTIMEIN VARCHAR2(25)
    INTROUTTIME VARCHAR2(25)
    PERTIMEIN VARCHAR2(25);
    PERTIMEOUT VARCHAR2(25);
    ATTEND_DATE DATE ;
    Consider that a table with 6 fields ie timein,intrtimein,pertimein,pertimeout,intrtimeout,timeout
    I have generating a attendance table and a table contain 6 various times for an employees and we need to arrange it in order
    0815,0816,1230,1250,1645,1646
    If 0815 is the starting time then timein ie mintime
    0816 stored to be in intrtime
    then1250 then it stored in pertimein
    then 1230 then it stored in pertimeout
    then 1645 stored in intrtimeout
    then 1646 stored in timeout
    I tried with max and min function but its not working properly pls tell me some solutions
    Thanks & Regards
    Srikkanth.M

  • How to use group function in insert or update

    Hai All
    How can we use group function in insert or update statement
    I am generating an attendance so i have different set of timing for example
    0800,1200,1230, 1700 and i need to insert into these data into table with min value to intime and max value to
    outtime and othere to inertval time in or out
    Pls tell me with some example
    For example
    For INSERT
    insert into T2 (barcode,empcode,intime,attend_date)
                   values(r2.cardn,r2.enpno,MIN(r2.ptime),r2.pdate);
    For UPDATE
    update dail_att set outtime= MAX(r2.ptime) where empcode=r2.enpno and barcode=r2.cardn and
    attend_date=r2.pdate;
    Here instead of where i need to use having so pls tell how to use
    Thanks & Regards
    Srikkanth.M

    Hai Man
    R2 is not a table name its a record
    Let me explain clearly
    I have to generate daily attendance for lot of employees So i have two table t1 and t2
    T1 consist of three column empno,date,time
    T2 consist of empno,name,date,intime,outtime,intrin,introut
    So now i need to give the T1 Min value Of time to T2 Intime and T1 Max value of Time to T2 Outtime fields so there so many records while i am using
    max(time) it gives the max value of all so i seperated by group function so now i have an error in subquery ie it is an single row subquery so i need to use multiple row subquery how i can use multiple row subquery in update statement
    Thanks In Advance
    Srikkanth.M

  • Iterating through List View Items using Group By and Jquery

    In my listview to my document library, I am using grouping. For each group (using month), it lists all the documents pertaining to that particular month.
    Using JQuery, I need to go through each item and parse them, but I'm having trouble finding a usable selector for the for/each function. My parsing code (JQuery) works, but since it uses the class of the table cell with a child anchor, it basically
    finds the first item and then all the subsequent file names are named the same (instead of different names, like it should be).
    Here's my current code that doesn't work (only the iteration and naming separately for each file - the parsing I'm doing seems to work):
    $(".ms-wpContentDivSpace" ).each(function( index ) {
    var val=$(".ms-vb2 a").html();
    var val2=val.replace(/_/g," ");
    $(".ms-vb2 a").html(val2);
    any ideas?

    That's because
    $(".ms-vb2 a").
    is bringing back all the pieces that have that class with an anchor on the whole page, not just the ones in the .ms-wpContentDivSpace
    I don't know the exact syntax, but I think you need to iterate through all the '.ms_vb2 a' items as well - there are multiple ones, and do something like this inside your other grouping
    $(".ms-vb2 a").each(function(index) {
        var val=$(this).html();
       var val2=val.replace(/_/g," ")
       $(this).html(val2);
    That's not quite right but maybe that will help.
    Robin

  • How to use GROUP BY  in ODI

    how to use GROUP BY in ODI tool

    Hi ,
    you can combine the insert stamt with the select ....so that in the target u will get a single line .....
    SQL&gt; select * from prop_details;
    PROPERTY RELAVANTD NOTICES
    10100 25-JAN-09 30
    10100 03-JAN-09 30
    10100 02-DEC-08 20
    10100 01-DEC-08 10
    10100 31-DEC-08 20
    10101 10-JAN-09 10
    10101 20-JAN-07 15
    10101 30-DEC-08 45
    10101 20-FEB-08 35
    10101 31-JAN-09 25
    10 rows selected.
    SQL&gt; select PROPERTY,max(RELAVANTDATE),SUM(NOTICES) from PROP_DETAILS GROUP BY P
    ROPERTY;
    PROPERTY MAX(RELAV SUM(NOTICES)
    10101 31-JAN-09 130
    10100 25-JAN-09 110
    SQL&gt;

  • Uninstall Lync 2010 client, Install Lync 2013 using Group Policy/VB/MS Customisation Tool

    Hi, I am using Group Policy/vb/Lync customization tools to deploy 2013 and remove 2010. The machines have Office 2010. The vb script is as below:
    Dim objShell 'As Object
    Dim objFSO 'As FileSystemObject
    '-- SET OBJECTS
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objShell = CreateObject("WScript.Shell")
    strComputerName = objShell.ExpandEnvironmentStrings("%COMPUTERNAME%")
    Dim WshNetwork : Set WshNetwork = WScript.CreateObject("WScript.Network")
    objShell.Run """\\xxxxxxxxx - Do not Remove\Lync Install 2013 2010\Lync 2013 Outlook 2010\setup.exe"""
    I have amended the OCT with relevant settings, Lync 2013 installs but Lync 2010 does not uninstall. Here is how i have it set:
    In the Office Customization Tool - Set-up - Add Installation and Run Programs,
    In target - pointing to the Lync2010 exe file (on above share)
    In Arguments - /silent /uninstall
    Is this correct?
    Also, i would have thought that, Remove Previous Installations, it would have an option to remove Lync2010?
    Anyway..pulling my hair out here!
    Hope you can help.

    Hi,
    Based on your description, we can refer to the following threads for help.
    Slient Unninstall of Lync 2010 on client machines script required
    http://social.technet.microsoft.com/Forums/lync/en-US/69e32128-4581-4be5-9a44-b5d133e1f480/slient-unninstall-of-lync-2010-on-client-machines-script-required
    Scripting a Lync 2010 client Uninstall
    http://social.technet.microsoft.com/Forums/en-US/a65bd0d0-daa1-4616-8725-63f349fdde86/scripting-a-lync-2010-client-uninstall?forum=lyncconferencing
    For this issue is more related to Lync, in order to get better help, we can ask the question in the following TechNet dedicated Lync forum.
    Lync 2010 and OCS - Lync Clients and Devices
    http://social.technet.microsoft.com/Forums/lync/en-US/home?forum=ocsclients&filter=alltypes&sort=lastpostdesc
    In addition, for it also involves scripts, we can also ask for help in the following scripting forum.
    The Official Scripting Guys Forum
    https://social.technet.microsoft.com/Forums/scriptcenter/en-US/home?forum=ITCG&filter=alltypes&sort=lastpostdesc
    Hope it helps.
    Best regards,
    Frank Shen

  • Use groups from BPMObject in JSP

    Hi all.
    Please, help me.
    I don't know jsp...but I find a little example project in Oracle BPM Studio, which describe the process of using jsp in BPM project. (JSP-Screenflow_FoodDelivery.exp) But there is no any code in this example how we should use groups from BPMObject in JSP. I mean that I don't know what I should do to input in my JSP table part (with dynamic rows). That’s why..can you write such example, or (better) give me such project in BPM (*.exp).
    Thanks.

    You will find the sample exp files under the samples folder where you installed Studio (this is the case for OBPM so I assume the same for ALBPM).
    I'm also interested on how others are using groups within jsps.
    I have a BPM object called 'Order' that has a group of 'OrderItems' and I want to fill in the 'Order' and add as many 'OrderItems' as required from within a JSP. The only way I've found to do this is have an automatic task before the interactive initialise the required number of 'orderItems' and then just update them in the jsp. Does anyone know a better way of doing this?
    Thanks,
    Mike

  • In mdx how to get max date for all employees is it posible shall we use group by in mdx

    in mdx how to get max date for all employees is it posible shall we use group by in mdx
    example
    empno  ename date
    1         hari        12-01-1982
    1         hari        13-06-2000
    by using above data i want to get max data

    Hi Hari3109,
    According to your description, you want to get the max date for the employees, right?
    In your scenario, do you want to get the max date for all the employees or for each employee? In MDX, we have the Max function to achieve your requirement. You can refer to Naveen's link or the link below to see the details.
    http://www.sqldbpros.com/2013/08/get-the-max-date-from-a-cube-using-mdx/
    If this is not what you want, please provide us more information about the structure of you cube, so that we can make further analysis.
    Regards,
    Charlie Liao
    TechNet Community Support

  • ORA-00907: missing right parenthesis when using group by clause with xmlagg

    I have the following query and I am getting ORA 00907 Error when I am using group by clause with the xmlagg function.
    select xmlelement("Mitigation",
                    xmlelement("m_szMethodName",tm.DisplayName),
                    xmlelement("SubstanceInterferenceProtocolList",
                                (select xmlagg(xmlelement("MitigationProtocol",
                                        xmlelement("m_szMethodName",tm.DisplayName),
                                        xmlelement("m_szInterferenceProtocolName",tmp.protocol_name),
                                        xmlelement("m_szInterferenceSubstance",tmp.intf_mtrl_prod_code),
                                        xmlelement("m_ProtocolParameters",
                                            xmlelement("m_szProtocolName",tmp.protocol_name),
                                                xmlelement("m_Consumables",
                                                    xmlelement("Consumable",
                                                        xmlelement("m_szConsumId", xrl.rgnt_pack_name),
                                                        xmlelement("m_szProductCode",xrl.pack_prod_code),
                                                        xmlelement("m_nVolume",tmp.fluid_vol),
                                                        xmlelement("m_szProtocolStep",xps.protocol_step_name))),
                                                    xmlelement("m_ProtParamList",
                                                        xmlagg(
                                                        xmlelement("ParameterValues",
                                                            xmlelement("m_szProtocolName",tmp.protocol_name),
                                                            xmlelement("m_Time",xpsd.parameter_ntime_value))
                                                        group by tmp.ccd_test_id,tmp.intf_mtrl_prod_code)
                    order by tmp.ccd_test_id, tmp.intf_mtrl_prod_code, xps.protocol_step_intprotocolstep )
                    from XPR_tdef_mitigation_protocol tmp, xp_reagentlist xrl,
                    xpr_protocol_settings xps, xpr_protocol_settings_default xpsd
                    where tmp.ccd_test_id = tm.ccd_test_id
                    and tmp.ccd_test_id = xrl.ccd_test_id
                    and tmp.pack_prod_code = xrl.pack_prod_code
                    and tmp.intf_type = 1
                    and xps.protocol_name = xpsd.protocol_name
                    and xps.protocol_step_name = xpsd.protocol_step_name
                    and xps.ps_action_parameterlist = xpsd.ps_action_parameterlist
                    and xps.protocol_name =  tmp.PROTOCOL_NAME
    from XPtoXPRTdef_defn_mapping tm
    where tm.DisplayName = 'SYPH'If I remove the xmlagg clause along with the group by clause, the query runs fine and give me the output.
    But in that XML format of the output is incorrect for my application.
    Could someone help here?

    Hi,
    userAtoZ wrote:
    I have the following query and I am getting ORA 00907 Error when I am using group by clause with the xmlagg function.
    ... xmlagg(
    xmlelement("ParameterValues",
    xmlelement("m_szProtocolName",tmp.protocol_name),
    xmlelement("m_Time",xpsd.parameter_ntime_value))
    group by tmp.ccd_test_id,tmp.intf_mtrl_prod_code)Please don't post unformatted code. When posting any formatted text on this site, type these 6 characters:
    \(small letters only, inside curly brackets) before and after each section of formatted text, to preserve spacing.
    If the code above were formatted well, so that you could match each '(' with its closing ')', it would look something like this:... xmlagg ( xmlelement ( "ParameterValues"
                        , xmlelement ( "m_szProtocolName"
                                       , tmp.protocol_name
                        , xmlelement ( "m_Time"
                                       , xpsd.parameter_ntime_value
    group by tmp.ccd_test_id
                        ,     tmp.intf_mtrl_prod_code
    This is exactly what you posted, only the whitespace has been changed.
    This makes it clear that the GROUP BY is inside the parentheses with the argument to XMLAGG.  You can have an ORDER BY clause there, but not a GROUP BY clause.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

Maybe you are looking for