Functions of nested groups

I thought that max (count ()) must be performed on separate groups of rows returned from GROUP BY deptno.
However, it seems that count() is performed according to GROUP BY while max() is performed on the result of count()... GROUP BY.
select max(count(deptno)) from emp group by deptno;
Why is this? How does the nested group functions operate against the GROUP BY?

PhoenixBai wrote:
I thought that max (count ()) must be performed on separate groups of rows returned from GROUP BY deptno.
However, it seems that count() is performed according to GROUP BY while max() is performed on the result of count()... GROUP BY.

select max(count(deptno)) from emp group by deptno;

Why is this? How does the nested group functions operate against the GROUP BY?

Well, look at the statement. There is nothing more than a "condensed" to form:

select max(cnt) from (select count(deptno) cnt from emp group by deptno)

Everything said is calculate number in each group deptno and then calculate max of counties. Another word, what you call "nested" grouping always returns a single line. GROUP BY clause, if any, still applies to the internal group. External pool always implicitly uses GROUP BY and therefore query always returns a line even when the internal grouping produces no line. Grouping in same way THAT HAVING applies inside. In fact, you cannot specify HAVING for the external group:

SQL> select max(sal) from emp group by deptno;

  MAX(SAL)
----------
      2850
      3000
      5000

SQL> select max(max(sal)) from emp group by deptno having max(sal) = 3000;

MAX(MAX(SAL))
-------------
         3000

SQL> select max(max(sal)) from emp group by deptno having (max(max(sal)) = 3000;
select max(max(sal)) from emp group by deptno having (max(max(sal)) = 3000
                                                          *
ERROR at line 1:
ORA-00935: group function is nested too deeply

SQL> -- You need to expand it

SQL> select max(max_sal) from (select max(sal) max_sal from emp group by deptno) having max(max_sal) = 3000;

no rows selected

SQL> 

SY.

Tags: Database

Similar Questions

  • How to display the column single line with function of nested groups

    SQL > select deptno, Max (sum (sal)) SalSum
    2 of PEM
    3 Group of deptno;
    Select deptno, Max (sum (sal)) SalSum
    *
    ERROR on line 1:
    ORA-00937: not a single group group function

    Can you please help me to get the Max (sum (sal)) with Deptno...

    Or:

    select max(deptno) KEEP (DENSE_RANK LAST ORDER BY SalSum) deptno,
    max(SalSum) from  (
      select deptno,sum(sal) SalSum
      from emp
      group by deptno
    );
    
  • Access a specific layer in a nested group

    OK honestly I feel a bit silly to ask this question, because it SHOULD be easy, but I simply cannot understand the proper syntax to do this. I have a layer I try to directly access a nested group, it is structured as:

    All the layers-> water-> water

    Where "All layers" and "Water" are the groups and 'Bodies of water' is the layer.

    I tried what I feel like is all the options, but the most logical for me would be:

    var test = layers myDocument.layerSets ["All"] ['water'] .layerSets .getByName ("water");

    Error 24: myDocument.layerSets ["All layers"].layerSets.Water.getByName is not a function;

    Not sure why its not read don't not formatting on the second table of games of layers. No matter what I try, I get an error, can anyone help?

    #target photoshop
    var doc = activeDocument
    var gp = doc.layers.getByName('Water')
    var gpLayer = gp.layers.getByName('Bodies Of Water')
    doc.activeLayer = gpLayer
    
  • What happened to the function "bookmark this group of tabs?

    Firefox 6.0 is not a function "bookmark this group of tabs" in the bookmarks menu. What happened to him? Still, can it be done? How? This is progress?

    Has been moved from the context menu of the tab. Right-click on a tab and you will see bookmark all tabs...

  • ACS 5.2 assignment of authorization with nested groups in LDAP

    I have a Cisco Secure ACS 5.2 on a virtual machine. We use it for administrative access to our equipment Cisco GANYMEDE +. I use LDAP to authenticate with acitive directory. I currently run when a user is directly in the group that is assigned.  I change the way in which assign us group permissions and have created nested groups.

    For example:

    -User1 is a member of group1

    g -roup1 is a member of the "Group 2".

    I have card group2 to have access to my devices. However, User1 is not get mapped to the Group of law and access is denied.

    When I go to the monitoring, reporting and authentication GANYMEDE + details, under other attributes where it shows the outside groups the user is a member, I don't see group2, only group1.

    However when User1 is a member of group2 directly, the user is able to log on.

    GBA 5.2 not does support permissions allow this how to use nested groups?

    Mapping of nested groups is not supported by LDAP (because users containing that attribute memberOf groups just above them, are not nested). It is a behavior deafult when we use nested with LDAP groups. You must add subgroups for GBA and both respective authorization rules.

    Kind regards

    Jousset

    The rate of useful messages-

  • Planning security with nested groups

    Hi all

    We have a CapEx Planning Application and have a problem with the security of the entity. We have users within their own groups of HSS. Some groups are nested in other groups. For example

    User1 is in Analyst_Group and Analyst_Group is in another group, Operations_Group.

    On a specific entity (11122), we give the Analyst_Group and Operations_Group write access no access.

    Planning should take the least restrictive security (for User1 in this case should be writable by 11122), but taking the security defined for Operations_Group. If set to None, then he cannot see this entity. If his game to play, then he gets only read access.

    Does anyone know why it does not work the way in which the Admin planning guides say it should (IE its not to take the least restrictive permissions)?

    We use the 11.1.2.1.0 planning.

    Thank you!

    Good read on the nested groups

    So in your case Operations_Group is the parent, then Analyst_Group will inherit the parent's access.

    Concerning

    Celvin

    http://www.orahyplabs.com

  • HELP to ' SQL error: ORA-00937: not a function of simple-group.

    < p >
    Hello world:

    I have a forum based on oracle 11g database. There two tables: article of thread and the relationship between the two is "one-to-many.

    I want to list the total number of seen of all the discussions in each section, and I write the sql code:

    Select s.secname, sum (sum1) of join of s section

    (select secid, sum1 sum (thrviewednum) of the Group of threads by secid) tt WE s.secid = tt.secid;



    The 'secid' column is the pharmacokinetics of the section table and FK of the table of thread, the "thrviewednum" the number of views of a thread.

    But I get the error:

    Error in the command line: 1 column: 7

    Error report:

    SQL error: ORA-00937: not a function of simple-group

    I can't understand the problem, could someone help me? Thank you.
    < /p >

    Hello

    Use this

    Select s.secname, sum (sum1) of join of s section

    (select secid, sum1 sum (thrviewednum) of the thread by secid group) THE group s.secid tt = tt.secid by s.secname;

    This is because the select statement contains a column that is not part of any group function, so this column must be there in the group by clause

    Concerning

  • Error based on nested groups used by column name.

    Hi team,

    If I used the function of group nested with column name his does not work. Could you please all you suggest me.

    How to use it.

    Kind regards
    Vincent.

    Please find coil...

    SQL > select user_name, max (max (CNT)) in (select USER_NAME, count (*) NTC from v$ open_cursor group USER_NAME)
    2 group user_name, CNT;
    Select user_name, max (max (CNT)) in (select USER_NAME, count (*) NTC from v$ open_cursor group USER_NAME)
    *
    ERROR on line 1:
    ORA-00937: not a single group group function


    SQL > select max (max (CNT)) in (select USER_NAME, count (*) NTC from v$ open_cursor group USER_NAME)
    2 group of user_name;

    MAX (MAX (CNT))
    -------------
    605

    Or simply (but it would be wrong if several users have same count (*)):

    select max(USER_NAME)keep(dense_rank first order by count(*)) username
          ,max(count(*)) CNT
    from v$open_cursor
    group by USER_NAME
    
  • How can I get the names of control within nested groups? RT

    I decided it was cool to have nested clusters. For example, all of the analog data, I read in my review is in a single cluster, which consists of categorical clusters (IE 'pressure', 'temperature', etc.). Now is the time to save data in the .tdms file, and it would be really handy generate a pair of paintings in this cluster 'root' containing all the digital control labels and their data.

    I found this thread, http://forums.ni.com/t5/LabVIEW/Is-there-a-quot-Get-Cluster-Names-quot-VI/td-p/666555, that uses a property node to retrieve the control labels in the root certification cluster. It's great, but I only get the labels of nested (and none of their items) clusters.

    My lab-fu is not strong enough to find an elegant solution for this. I can brute force of unbundling and indicators, then using the property noted separately on them... but I think there must be a better way!

    The attached VI is my best effort to solve this. It works, but I fear that it is not the best code for the following reasons:

    1. am I really allowed to point to elements of the façade at RT will be deployed this Subvi in one executable startup?

    2. If the Subvi is in a loop, what should I do instead of 'build array' in order to avoid the memory use? All examples use it I read so much about how I shouldn't... and what the functional alternative?

    Thanks a lot for your time!

    Here's a version that uses the variant screws, will take care of any level of nesting and work on RT. The use of Delete of table and table to build is not too efficient, but should not be a problem if you only run this once when the program starts. If you use the Type Cast to convert a cluster in a table as shown here, all numerical values should have the same representation (IE do not mix single and double-precision floating points, or integers (ints) and floating point values), otherwise you will get weird data without warning or error.

    Also, your original code had a displacement uninitialized register. Pay attention to that - if you were to run this code twice, the second time that the table of data labels would be twice longer as it should be, because the shift register would be initially contains the values in the first round.

  • Function Sum() in GROUP BY for return null if all lines aggregate is NULL

    Consider the following FOO table:

    COL_A VAL_A VAL_B
    A12
    ANULL VALUE2

    and the sql code:

    SELECT COL_A, SUM (VAL_A) VAL_A

    FOO

    COL_A GROUP;

    Returns

    COL_A VAL_A
    A1

    Is there a way to make the SUM() values if and only if all of the aggregated lines are not NULL?

    I want to return is:

    COL_A VAL_A
    A

    NULL VALUE

    If all of the aggregated rows are not null, the normal SUM() function is made.

    SELECT COL_A, SUM (VAL_B) VAL_B

    FOO

    COL_A GROUP;

    Returns

    COL_A VAL_B
    A4

    WITH (FOO AS

    SELECT COL_A, VAL_A 1, 2 VAL_B OF THE DOUBLE ' A'

    UNION ALL SELECT 'A' COL_A, VAL_A, 2 VAL_B OF THE DOUBLE NULL

    )

    SELECT NULLIF (0, MAX (DECODE(VAL_A,,0))) + SUM (VAL_A) IN FOO GROUP OF COL_A;

  • search criteria for groups vCops 5.6: child vs Descendant of?  + Nested groups...

    What is the difference between ascending to and Parent of / Descendant of and the child of?

    Also if I nest a group is a way to add the children of groups of children to parent group?

    For example:

    • Parent group: racks 1
    • Child group: BladeChassis1

    Can I create a rule to search on racks 1 group that will add children from BladeChassis1 to 1 racks as well.  This measure metric level additional host level racks 1.   I would go a little further and adds the VM guests in the BladeChassis1 to 1 racks as well.  This would allow the additional to consider level racks 1 VM metric.   I know that I can manually add virtual machines, but it won't work because virtual machines are able to migrate between hosts.

    Worse, I would create Super Metrics.   It just hurts to create Super Metrics, if summary data are available in the default user interface.

    Thank you

    -MattG

    Hi Matt,

    I guess I was not clear enough. "An object must match all of the criteria in this rule set to become a member of the group" - it's quite true. What I propose is to create two 'sets', each containing a criteria. individual rule sets are joined with the logical OR operator. Just click on the "Add a new set of rules" link and you will figure it out.

    Let me know if you still not the desired behavior, and I'll upload a screenshot of tomorrow to illustrate

  • How to use the Pivot function for range group in oracle SQL

    Hello

    Hello!!!

    I need to display the data in the format below. There are 2 columns 1 is State and another is rate.

    State < 100 100-199, 200-299 300-399 400-499, 500-599 600-699 700-799 800-899 900-999 > = 1000 Total
    AK 1 2 0 4 1 4 4 35 35 4 1 25
    AL 0 0 2 27 10 17 35 2 2 35 0 103
    AR 0 0 1 0 0 2 2 13 13 2 0 6
    AZ 0 1 2 14 2 14 13 3 3 13 0 57
    CA     0     0     1     6     2     7     3     4     4     3     0     34

    Developed the sub query but unable to use the beach on the pivot function. Please help on this.

    (select (SELECT short_description
    OF CODE_VALUES
    WHERE CODE_TYPE_CODE = ad. STATE_TYPE_IND_CODE
    AND VALUE = ad. STATE_CODE
    ) STATE,
    Nr.rate
    N-NEUTRAL
    c contacts,
    announcement of addresses,
    xref_contacts_addresses xca,
    neutral_rates nr
    where n.contact_id = c.contact_id
    and n.address_id = ad.address_id
    and xca.address_id = ad.address_id
    and xca.contact_id = c.contact_id
    and nr.contact_id = n.contact_id
    and nr.rate_frequency = 'HOUR')

    Like this

    with t
    as
    (
    select 'AL' state, 12 value from dual union all
    select 'AL' state, 67 value from dual union all
    select 'AL' state, 23 value from dual union all
    select 'AL' state, 12 value from dual union all
    select 'AL' state, 12 value from dual union all
    select 'AL' state, 78 value from dual union all
    select 'AL' state, 34 value from dual union all
    select 'AL' state, 4 value from dual union all
    select 'AL' state, 12 value from dual union all
    select 'AL' state, 15 value from dual union all
    select 'AZ' state, 6 value from dual union all
    select 'AZ' state, 123 value from dual union all
    select 'AZ' state, 123 value from dual union all
    select 'MA' state, 23 value from dual union all
    select 'MA' state, 120 value from dual union all
    select 'MA' state, 456 value from dual union all
    select 'MA' state, 11 value from dual union all
    select 'MA' state, 24 value from dual union all
    select 'MA' state, 34 value from dual union all
    select 'MA' state, 87 value from dual union all
    select 'MA' state, 23 value from dual union all
    select 'MA' state, 234 value from dual union all
    select 'MA' state, 789 value from dual union all
    select 'MH' state, 54321 value from dual
    )
    -- End of test data
    select state,
           nvl(count(decode(value, 0, 0)), 0) "<100",
           nvl(count(decode(value, 1, 1)), 0) "100-199",
           nvl(count(decode(value, 2, 2)), 0) "200-299",
           nvl(count(decode(value, 3, 3)), 0) "300-399",
           nvl(count(decode(value, 4, 4)), 0) "400-499",
           nvl(count(decode(value, 5, 5)), 0) "500-599",
           nvl(count(decode(value, 6, 6)), 0) "600-699",
           nvl(count(decode(value, 7, 7)), 0) "700-799",
           nvl(count(decode(value, 8, 8)), 0) "800-899",
           nvl(count(decode(value, 9, 9)), 0) "900-999",
           nvl(count(decode(value, 10, 10)), 0) ">=1000"
      from (
              select state, case when value < 100 then 0
                                 when value between 100 and 199 then 1
                                 when value between 200 and 299 then 2
                                 when value between 300 and 399 then 3
                                 when value between 400 and 499 then 4
                                 when value between 500 and 599 then 5
                                 when value between 600 and 699 then 6
                                 when value between 700 and 799 then 7
                                 when value between 800 and 899 then 8
                                 when value between 900 and 999 then 9
                                 when value >= 1000 then 10
                            end value
                from t
           )
     group
        by state
    
  • Bug with the aggregate function and no group

    When I run the following query:
    with the_table as
    (
      select 1 as id, 100 as cost from dual
      union all select 2 as id, 200 as cost from dual
      union all select 3 as id, 300 as cost from dual
      union all select 4 as id, 400 as cost from dual
      union all select 5 as id, 500 as cost from dual
    )
    select id, cost
    from
    (
      select id, cost
      from the_table
      --
      union all
      --
      select 0 as id, sum(cost) as cost
      from the_table
      where 0 = 1
      -- group by 1
    )
    order by id;
    I get this result:
    ID    COST
    --  ------
     0  <null>     
     1     100
     2     200
     3     300
     4     400
     5     500
    However, when I "uncomment" the line "Group 1", the query works as expected (without the id = rank 0).

    This occurs even when "the_table" is an array.

    Someone else comes through this (and if so, how long is a problem)?

    The database is 11.2.0.2.0 64-bit.

    EDIT: It also happens without a Union - the following returns a single line (with null 0 and cost of id) without the Group By and no line with her:
    select id, cost
    from
    (
      select 0 as id, sum(cost) as cost
      from 
      (
        select 1 as id, 100 as cost from dual
        union all select 2 as id, 200 as cost from dual
        union all select 3 as id, 300 as cost from dual
        union all select 4 as id, 400 as cost from dual
        union all select 5 as id, 500 as cost from dual
      )
      where 0 = 1
      -- group by 1
    )
    order by id
    Edited by: Donbot February 15, 2012 10:29

    Donbot wrote:
    Someone else comes through this (and if so, how long is a problem)?

    The database is 11.2.0.2.0 64-bit.

    This is a documented behavior.

    http://docs.Oracle.com/CD/E11882_01/server.112/e26088/functions003.htm#SQLRF20035

    "
    All except COUNT (*) GROUPING and GROUPING_ID aggregate functions ignore NULL values. You can use the NVL function in the argument of an aggregation function to substitute a value for a null value. COUNTY and REGR_COUNT never return null, but return a number or zero. For all remaining functions of aggregation, * if the DataSet contains no line, * or if it contains only the rows with NULL values as arguments to the aggregate function, * then the function returns null.*
    "

  • Function to start Group BOX

    Hello

    I am creating a form with a group that contains a section with a trigger which repeat as many times he finds the lines in the XML file. I want to surround this group with a margin box. How can I do?

    I tried to use the GroupBegin function, but I got and error that it can not locate the box.

    Thank you.

    Hello

    If you are using the group option Add to the Documaker studio, you can get this kind of error. Please try to place a box in an article and code GroupBegin and rules of box in this article and the code of all the Sections that are under him, and finally a section with GroupEnd.

    Thank you.

  • RTF model: are with nested groups

    Hi all

    I have a certain pickle of a problem that apparently...

    my data structure looks like this:

    <>COMPANY
    -< STORE >
    -Department < AND >
    -< ITEM > < / ITEM >
    -< / DEPARTMENT >
    -< / STORE >
    < / COMPANY >

    several companies may have several banks, which in turn have several departments, which, in turn, may also have several elements.

    my select statement looks like this:

    Select company_id,
    store,
    Department,
    agenda,
    Sum (Qty) as my_sum
    Of
    table_1, table_2, table_n
    where the...
    Group of...
    company_id order;

    my xml data model gathering looks something like this:

    < name of the group = "G_company"...
    -< element name = "E_company"...
    -name of the group = "G_store"...
    -< element name = "E_store"...
    -name of the group = "G_department"...
    -< element name = "E_department"...
    -name of the group = "G_item"...
    -< element name = "E_item"...
    -< element name = "E_item_total" value = "my_sum"...
    -< / Group >
    -< element name = "E_department_total" value = "G_item. E_item_total"function =" SUM () "/ >"
    -< / Group >
    -< element name = "E_store_total" value = "G_department. E_department_total"function =" SUM () "/ >"
    -< / Group >
    < / Group >

    my report currently looks like this:

    -< /B > < b > store-Dept of < b > < /b > - Dept of < b > < /b > - < b > point < /b > - < b > < /b > - point store < b > < /b > - Dept of < b > < /b > - < b > < /b > - < b > < /b >
    ---Townsville---TDept_1---TDept_2---TDItm1---TDItm2---Newcastle---NDept1---NDItm1---NDItm2 company < /b > < b >
    ---CompanyA------2----------------4------------3---------------2---------------1------------------1-------------------3----------------2-------------------4
    ---CompanyB------1----------------2------------4---------------5---------------2------------------1-------------------6----------------3-------------------1


    If I focus just on the Store-> Department-> order of the day, I realized that in my RTF using the template as follows:

    < table >
    -< tr >
    -< td > <? for-each-group@column:G_store; E_store? > shop < table > < td > <? for-each-group@column:G_department; E_department? > Department < table > < td > <? for-each-group@column:G_item; E_item? > element <? end for each group -? > <? end for each group -? > <? end for each group -? > < table >
    -< /tr >
    -< tr >
    -< td > <? for-each-group@column:G_store; E_store? > <? E_store_total? > < table > < td > <? for-each-group@column:G_department; E_department? > <? E_department_total? > < table > < td > <? for-each-group@column:G_item; E_item? > <? E_item_total? > <? end for each group -? > <? end for each group -? > <? end for each group -? > < table >
    -< /tr >
    < /table >


    as you can see, the store-> Department-> point go through the report horizontally.
    My problem is I want to have the totals for each column, such as:

    -< /B > < b > store-Dept of < b > < /b > - Dept of < b > < /b > - < b > point < /b > - < b > < /b > - point store < b > < /b > - Dept of < b > < /b > - < b > < /b > - < b > < /b >
    ---Townsville---TDept_1---TDept_2---TDItm1---TDItm2---Newcastle---NDept1---NDItm1---NDItm2 company < /b > < b >
    ---CompanyA------2----------------4------------3---------------2---------------1------------------1-------------------3----------------2-------------------4
    ---CompanyB------1----------------2------------4---------------5---------------2------------------1-------------------6----------------3-------------------1
    ---<b>Total</b>------------3----------------6------------6---------------7---------------3------------------2-------------------9----------------5-------------------5

    so I did a SUM on each of the Department/E_store/item_totals as:

    <? sum (current - group () / E_store_total)? >

    who now works for E_store_total... but not for E_department_total and E_item_total!
    It seems that BI Publisher does not like used money with inner loops.
    because if I extract only the column for E_department, the total value down is correct!
    but once I put the outside loop store, it breaks.

    what I get now with is:

    -< /B > < b > store-Dept of < b > < /b > - Dept of < b > < /b > - < b > point < /b > - < b > < /b > - point store < b > < /b > - Dept of < b > < /b > - < b > < /b > - < b > < /b >
    ---Townsville---TDept_1---TDept_2---TDItm1---TDItm2---Newcastle---NDept1---NDItm1---NDItm2 company < /b > < b >
    ---CompanyA------2----------------4------------3---------------2---------------1------------------1-------------------3----------------2-------------------4
    ---CompanyB------1----------------2------------4---------------5---------------2------------------1-------------------6----------------3-------------------1
    ---<b>Total</b>------------3----------------4------------3---------------2---------------1------------------1-------------------3----------------2-------------------4

    It makes the total general store correctly, but it gives me just the first line for the other totals.

    I tried:

    1 using the CUBE function in my SQL query, which gives me the results I want with all the totals I want, but I can't translate it into XML.
    2. try to use the pivot table option, but I can't always make it work as I want.
    3. using a separate sql query to retrieve the grandtotals but cela does not either because the required multiple looping.

    I am at a complete impasse, any help would be really appreciated!
    PS. I'm a very cool beginner

    Sent the hotfix.

    You must use the current group.

Maybe you are looking for

  • How to stop script error messages?

    Under Win XP home sp3THAT IS TO SAY 8OE 6MSE 1.0.1611For 3-4 weeks I get script error messages everyday when you open e-mails on OE6. I am not aware of changing settings of IE or OE. Under IE-Tools-Options-Advanced-browsing the Internet the following

  • Value of money to upgrade?

    I am currently shooting with a T3i and have been very satisfied with the results.  I have considered upgrading to full frame, but the price and the investment I made in the EF-S-objectives makes me shy away for now.  I was wondering if it would be wo

  • WRT54G V8 power and custom light LAN light up

    Ive recently tried to update the firmware and everything went according to the instructions, then the power and light of the LAN are out. Now I have the led lights for the computer and the modem, but it is. No internet or SSID not broadcast. I cannot

  • Hard drive full no reason disk space

    I just had a dv6 4 weeks ago and it has more than 600 GB of hard drive and now I only have 1.27 MB left. I have no idead how it happened. There is no way I have the programs/software that take a lot of space. Help, please

  • Origin of the dashboard alarm

    Hi all I played with capacity of Foglight to monitor for specific events in the Windows event logs.  I have it working (I think!), but face a slight problem. I copied the OOTB EventLog rule and renamed it as the name Windows event log.  The OOTB Even