Restrict Query display to TopN with Group BY

Hello Experts,
I have a query on a multiprovider that display the following results
Plant     Product          Date          Qty
ABC     Mat001          07/03/2007     35
ABC     Mat001          07/05/2007     20
ABC     Mat001          07/09/2007     99
ABC     Mat001          07/11/2007     55
ABC     Mat002          07/05/2007     45
ABC     Mat002          07/09/2007     20
ABC     Mat002          07/11/2007     75
ABC     Mat002          07/15/2007     49
Now I want to restrict and display each product that has max Qty as below
Plant     Product          Date          Qty
ABC     Mat001          07/09/2007     99
ABC     Mat002          07/11/2007     75
If I use TopN condition on Plant, Product, Date I will only get one record but I want Max of Qty for each product like Group By Plant, Product, Date.
Any advice is appreciated.
Thanks,
John Li

Hi John,
It is obvious if you are giving N as 1 then only one value will be displayed that is topmost value.
Since your  the number of records that has to be displayed is not static, create a condition on all the three characteristic as mentioned in the earlier post and use some maximum value for N like 9999999

Similar Messages

  • Display column name with Group by

    Hi,
    I am having a table with a column series which is repeating.
    When i want to get all the unique series and its count, in the normal sql, I am using
    select series,count(1) from temp_table group by series;
    But the same is not working in the case of SQLX,
    I want <root><series><name count="8">series1</name><name count="18">series2</name></series></root> kind of output.
    But when i use SQLX query,
    select XMLElement("root",XMLElement("series",XMLAgg(XMLElement("name", ... group by series
    it is returning more than one record.
    How to get the desired result??
    Thanks
    Guru

    I wanted to know whether it is possible to get the count in the sqlx itself, Can anybody point me to any SQLX query for that?

  • Problem with "Group By" in Views - Not Displaying the Same for All Users

    We have an Announcements List with its only View being set up to group by a metadata category field. We've done this many times on other kinds of lists and never had a problem. But with this list, about half the users can see only the ungrouped
    set of announcements, whereas others actually see the items within their groups.
    Those with "View" rights only can't see the grouped items - but that appears to be a coincidence as I promoted them to the same rights as others who can see them correctly, and that did NOT solve the problem. Everyone is using the exact same browser.
    Note: the users who do NOT see the groupings see only a single category entry that displays only the name of the category list (but not the names of the actual categories within the category list). All the announcements are grouped under that one
    entry for those users. This display looks exactly like it would if the categories had been left blank when the original announcements were created. But the categories are NOT blank, and the rest of the users can see them just fine, and the announcements display
    within their appropriate groups.
    I can't find anything in the View, the List Settings, or the User Permissions to explain this. What could be causing it, and how can I fix it?

    Browser settings are controlled by central IT and are all identical. 
    The only difference I can detect is the second set of users (that don't see the category options) have only Read rights, whereas those with Contribute (or above) rights can see the categories. It doesn't make
    sense that permissions would affect this, but I can't come up with any other differences.
    Microsoft will not allow me to upload images. it says I can't upload images until they have verified my account, but there is no clue as to how, if or when that might happen. If you can tell me how to fix that, I can provide samples.

  • Restrict Vendor line items display by Vendor authorization group

    Hi Gurus,
    I have a requirement to restrict Vendor line item diplay for Tcode FBL1N, I have updated the Authorization object F_LFA1_BEK, its work fine if all the vendors have authorization, However it also display vendors whose auth. group is "BLANK" or "SAPCE",
    Is there a way that I can slove this issue, is there any SAP notes of other object which needs to be updated ?

    Hi,
    this problem has been discussed on this forum last week. Basically, SAP does not perform authorization check if the authorization group is blank. Hence you need to assign authorization object to all vendors.
    Cheers

  • View/table V_T682 can only be displayed and maintained with restrictions

    Hi friends,
    When I want to displaying for V_T682 table  from  SM30 tr.code , it gives me about error "  View/table V_T682 can only be displayed and maintained with restrictions". I think ,this table's maintenance status is  marked as  display/maintenance allowed with restrictions on SE11. So, how I can display the this table from sm30 tr.code.(Note: I have only displaying authorization)

    Hi Lakshmipathi
    I already knowing to execute the tables from se16 tr.code,  My aim is to displaying the customizing view.(Note: I have no authorization for SM34 tr.code.)
    Edited by: kaiz34 on Sep 20, 2010 4:51 PM
    Edited by: kaiz34 on Sep 20, 2010 4:52 PM

  • Query to display the tables with referential integrity

    Hello,
    I need to display the Tables which are having referential integrity..
    Like need to dispaly the parent and child tables
    Please give me some idea on this..
    Thanks,

    Here's a nice query you can use:
    with temp_constraints as (
    select table_name
    ,      constraint_name pkey_constraint
    ,      null fkey_constraint
    ,      null r_constraint_name
    from   user_constraints
    where  constraint_type = 'P'
    union all
    select a.table_name
    ,      a.constraint_name pkey_constraint
    ,      b.constraint_name fkey_constraint
    ,      b.r_constraint_name
    from   user_constraints a, user_constraints b
    where  a.table_name = b.table_name
    and a.constraint_type = 'P'
    and b.constraint_type = 'R'
    select rpad( '*', (level-1)*2, '*' ) || table_name relation
    from   temp_constraints
    start with fkey_constraint is null
    connect by pkey_constraint <> r_constraint_name
    and prior  pkey_constraint = r_constraint_name;From http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:661009003696#tom69115451356231

  • New iMac with Retina display has attracted a group of ants. Why?

    New iMac with Retina Display has attracted a group of ants to nest in it, while they ignore my old Macbook Pro. What is in the new laptop that attracts the ants? The Apple Support set me up with an appointment at an Apple Store and the Apple Store says it is Apple policy not to touch it with the Ants in it. Wasted 2.5 hours in travel time and in the store with no solution.

    Its the electrical charges that attract them, they sense them as other critters to eat / talk with 
    the swarm of tiny DC power fields inside a computer, and the charges across the screen attract insects that have EM sensors on their exoskeletons. Its a come hither spotlight for insect critters.
    http://answers.yahoo.com/question/index?qid=20070523002354AA340iK
    If you want them out, which of course you do.......make a sugar trap for them.... a trail from the computer to a little pile.  One screams the treasure to the others, .....they all come running, then you brush them away, or some other insidious method. 
    See this one:
    http://www.sfgate.com/technology/businessinsider/article/Crazy-Ants-That-Eat-Ele ctrical-Equipment-Are-4533102.php

  • Query to find the request group associated with a responsibility

    Hi All,
    I have to attach a report to around 30 responsibilities. For this I will have to find the request group for each responsibility and then add the Concurrent Program for the report in the corresponding request group.
    Can anyone help me with a query to find the request group associated with a responsibility.
    Regards,
    SK

    Just to add to the query above, if you want to see request group along with request_group_id you do join as follows
    SELECT frv.responsibility_name
    ,frg.request_group_name
    FROM fnd_request_groups frg,
    fnd_request_group_units frgu,
    fnd_responsibility_vl frv
    WHERE 1 = 1
    AND frgu.request_group_id = frg.request_group_id
    AND frv.request_group_id = frg.request_group_id
    ORDER BY responsibility_name
    Thanks
    Shailendra

  • Incorrect warning when parsing query with group by clause

    I am using SQL Developer 4.0.0.13.80 with JDK 1.7.0_51 x64 on Windows 8.1
    I have the following SQL, which works perfectly:
    select substr(to_char(tot_amount), 0, 1) as digit, count(*)
    from transactions
    where tot_amount <> 0
    group by substr(to_char(tot_amount), 0, 1)
    order by digit;
    However, SQL Developer is yellow-underlining the first line, telling me that:
    SELECT list is inconsistent with GROUP BY; amend GROUP BY clause to: substr(to_char(rep_tot_amount), 0, 1), substr(to_char(rep_tot_amount),
    which is clearly wrong.
    Message was edited by: JamHan
    Added code formatting.

    Hello,
    I also have found the same issue with the GROUP BY hint. Another problem I found is that the hint suggests to amend the GROUP BY members to add also constant values that are included in the SELECTed columns and whenever those constants include strings with spaces, it generates an invalid query. Normally, constant values won't affect grouping functions and as such they can be omitted from the GROUP BY members, but it seems SQL Dev thinks it differently.
    For example, if you try the following query:
    SELECT d.DNAME, sum(e.sal) amt, 'Total salary' report_title, 100 report_nr
    FROM scott.emp e, scott.dept d
    WHERE e.DEPTNO = d.DEPTNO
    GROUP BY d.DNAME;
    when you hover the mouse pointer on the yellow hint, a popup will show the following message:
    SELECT list inconsistent with GROUP BY; amend GROUP BY clause to:
    d.DNAME, 'Total, 100
    If you click on the hint, it will amend the group by members to become:
    GROUP BY d.DNAME, 'Total, 100;
    that is clearly incorrect syntax. You may notice that after the change the yellow hint is still there, suggesting to amend further the GROUP BY members. If you click again on the hint, you will end with the following:
    GROUP BY d.DNAME, 'Total, 100;
    , 'Total, 100
    and so on.
    I am not sure if this behaviour was already known (Vadim??), but it would be nice if somebody could file a bug against it.
    Finally when writing big queries with complex functions and constant columns, those yellow lines extend all over the select list and they are visually annoying, so I wonder if there is a way to disable the GROUP BY hint until it gets fixed.
    Thanks for any suggestion,
    Paolo

  • AD query -- trouble with group.member list

    Hello,
    I'm attempting to create an AD query that filters for certain groups and all the members of those groups. I start with the groups table and filter to get the groups of interest. No problems so far.
    When I expand the group column to pick up the "member" column, I get group.member and the cell values have changed from "Record" to "List."  When I expand "List" I can tell I'm at the right level of granularity,
    because the number of rows has increased, and the group names are repeated for the number of members in a group. The problem is that the group.member field now shows "Record" again. I can't expand on it. And when I click on any of the "Record"
    links, I can see the individual's name.
    Any ideas on how I'm to get the name to show up in the full result set rather than needing to click on the "Record" link? Searching for "Power Query" with "record" has been...unhelpful (expectedly so).
    Thanks

    Gil,
    Thanks for the reply. I notice that in my query, displayName is null for all the records returned. I have been able to get the group name information from the sAMAccountName field, although I wonder if that is what is causing the issue when I attempt to
    expand. 
    Here are more details on my query stages:
    The first stage is with the following query (I left the "GL" filter visible since by itself it's not confidential):
    let
        Source = ActiveDirectory.Domains(<domain>),
        <domain> = Source{[Domain=<domain>]}[#"Object Categories"],
        group1 = <domain>{[Category="group"]}[Objects],
        #"Expand securityPrincipal" = Table.ExpandRecordColumn(group1, "securityPrincipal", {"sAMAccountName"}, {"securityPrincipal.sAMAccountName"}),
        #"Filtered Rows" = Table.SelectRows(#"Expand securityPrincipal", each Text.StartsWith([securityPrincipal.sAMAccountName], "GL"))
    in
        #"Filtered Rows"
    The second stage (1st screenshot) is immediately after I expand the group column and select "member." I show the bottom view, too, which shows the three records associated with this list (the correct number of users in that AD group).
    When I "expand" group.member, it changes from List to Record and there is now one row for each user in a group. However, when I go to pick the displayName column from group.member, it gives me the message "No columns were found." Yet,
    when I select the group.member value, I can see in the view below that there is a displayName. (See 2nd screenshot.) Note that I filtered the records in the third screenshot to just a single group -- 3 records.
    Does this additional information help isolate what I might be experiencing?
    Here is the query to match the final screenshot:
    let
        Source = ActiveDirectory.Domains(<domain>),
        <domain> = Source{[Domain=<domain>]}[#"Object Categories"],
        group1 = <domain>{[Category="group"]}[Objects],
        #"Expand securityPrincipal" = Table.ExpandRecordColumn(group1, "securityPrincipal", {"sAMAccountName"}, {"securityPrincipal.sAMAccountName"}),
        #"Filtered Rows" = Table.SelectRows(#"Expand securityPrincipal", each Text.StartsWith([securityPrincipal.sAMAccountName], "GL")),
        #"Expand group" = Table.ExpandRecordColumn(#"Filtered Rows", "group", {"member"}, {"group.member"}),
        #"Expand group.member" = Table.ExpandListColumn(#"Expand group", "group.member"),
        #"Expand top" = Table.ExpandRecordColumn(#"Expand group.member", "top", {"name"}, {"top.name"}),
        #"Removed Columns" = Table.RemoveColumns(#"Expand top",{"msExchIMRecipient", "ciscoEcsbuUMAttributes", "posixGroup", "top.name", "msExchBaseClass",
    "msExchCustomAttributes", "mailRecipient"})
    in
        #"Removed Columns"
    Scott C.

  • A query to display sales orders with corresponding outbound deliveries

    Hi Experts,
    Don't know if this is the right place to post the question but i would like to know if a query, in SAP, can display sales orders with their corresponding outbound deliveries, i tried using table LIKP and VBAK, VBKD didn't help. the whole idea is to enter any specified sales order number and the query will return any outbound deliveries belong to the sales order.
    Thanks in advance!

    run the se16 transaction - table VBFA.
    This table gives the Sales document flow.
    Give the sales order nos. and in the subsequent document category select delivery.
    You will get all deliveries.
    Thanks
    Ajay

  • Hi,report like roles with groups display?

    i am having roles /groups like following
    String arrRoles = {"devloper","admin","manager","clerk","other"};
    String arrGroups={"grp1","grp2","grp3","grp4","grp5","grp6"};
    each groups having separate access
    grp1 roles manager,developer
    grp2 roles manager,clerk,other
    grp3 roles clerk,admin
    grp4 roles other
    grp5 roles manager,develoepr,admin,clerk,other
    grp6 roles clerk,other
    finally after reading two array values and each group roles ,
    i need to values in report like this
    report
    role grp1 grp2 grp3 grp4 grp5 grp6
    devloper yes no no no yes no
    admin no no yes no yes no
    manager yes yes no no yes no
    clerk no yes yes no yes yes
    other no yes no yes yes yes
    i need to display values if the group having role need to display
    yes otherwise no.
    can any one help me how to do and display
    here roles and groups are not fixed values both are dynamicaly
    created arry objects
    thanks in addvance
    sai

    hi,
    thanks for your example.
    any way i solved this issue my self another way.
    class Report3Test
         public static void main(String str[])
              String[] arrRoles = {"develop","admin","manager","clerk","other"};
              String[] arrGroups = {"grp1","grp2","grp3","grp4","grp5","grp6"};
              String arGrp1[] ={"manager","develop"};     
              String arGrp2[] ={"manager","clerk","other"};
              String arGrp3[] ={"clerk","admin"};
              String arGrp4[] ={"other"};
              String arGrp5[] ={"manager","develop","admin","clerk","other"};
              String arGrp6[] ={"clerk","other"};
              String DELIMINATOR = "\t";
              String strGroups = "";
              strGroups = "Roles"+DELIMINATOR;
              for(int i =0; i<arrGroups.length;i++)
                   strGroups = strGroups+arrGroups[i]+DELIMINATOR;
              System.out.println(strGroups);
              for(int i =0; i<arrRoles.length;i++)
                   String groupStatus1 = "No";
                   String groupStatus2 = "No";
                   String groupStatus3 = "No";
                   String groupStatus4 = "No";
                   String groupStatus5 = "No";
                   String groupStatus6 = "No";
                   for ( int k =0; k<arGrp1.length;k++)
                        if(arGrp1[k].equals(arrRoles))
                             groupStatus1 = "Yes";
                   for ( int k =0; k<arGrp2.length;k++)
                        if(arGrp2[k].equals(arrRoles[i]))
                             groupStatus2 = "Yes";
                   for ( int k =0; k<arGrp3.length;k++)
                        if(arGrp3[k].equals(arrRoles[i]))
                             groupStatus3 = "Yes";
                   for ( int k =0; k<arGrp4.length;k++)
                        if(arGrp4[k].equals(arrRoles[i]))
                             groupStatus4 = "Yes";
                   for ( int k =0; k<arGrp5.length;k++)
                        if(arGrp5[k].equals(arrRoles[i]))
                             groupStatus5 = "Yes";
                   for ( int k =0; k<arGrp6.length;k++)
                        if(arGrp6[k].equals(arrRoles[i]))
                             groupStatus6 = "Yes";
                   String roleParam = (String)arrRoles[i];
                   System.out.println(roleParam+DELIMINATOR+groupStatus1+DELIMINATOR+groupStatus2+DELIMINATOR+groupStatus3+DELIMINATOR+groupStatus4+DELIMINATOR+groupStatus5+DELIMINATOR+groupStatus6);               
    ===================
    sai

  • DISPLAY RUNNING TOTAL IN GROUP HEADER

    Post Author: sharonmtowler
    CA Forum: Formula
    I know there is a way to do this, just forgot how. i am in version 8.5.  i have a manual running total which calculates order qty for the entire sales order.i (dont like using the rt wizard-buggy)
    the knowledge base says to use a cross tab, but there hit or miss also.
    does anyone know how to show the display formula for a manual runnning total in the group header instead of group footer?

    Post Author: pandabear
    CA Forum: Formula
    Hi Sharon,
    I wanted to try this before I sent it to you, but my Crystal is down because (blah, blah, long story here....yawn....).
    I think I understand.  You want to show the "Total" for each group, in the group header instead of the group footer?
    My experience is that Crystal works from the top down (read: limiting), so I need a work around to do this.
    1 - Do the calculation in the query...sum by group, filter with a "Case" statement, etc.  If there's a reason you can't do that then
    2 - (and this is what I wanted to try first) see if you can group on the same field twice. 
    Group 1 - Test.field
    Group 2 - Test.field (same field)
    If you can,
    then just carry the total from the group footer of the previous group (same field) above you, and bring it down
    (shared var ?) to the group below.
    My 2 cents is up.
    Hope this helps,
    The Panda

  • Matrix report with group.

    dear all,
    can anyone guide me how to build a matrix report with group using scott schema.
    i can not be able to build a query.
    Thanks
    Muhammad Nadeem

    The example given by Oracle (from the above link) using the following SQL for a matrix report is flawed.
    SELECT DEPTNO, JOB, SUM(SAL)
    FROM EMP
    GROUP BY DEPTNO, JOB
    ORDER BY DEPTNO, JOB
    The SUM function handled by the query restricts you from doing so many things - especially when you want the empty fields to be filled by 0 (by using the Value if Null property).
    If the query is changed to ''SELECT DEPTNO, JOB, SAL FROM EMP' , and use the SUM function in the wizard to build the Matrix cell, then the 'Value if Null' property can be used without any issues.
    This also makes Section 25.6 (Add zeroes in place of blanks) of the documentation a joke.
    Anyway, that's my cents worth....

  • Display apex report with subqueries

    How to display apex report with main query contains sub quires and sub query returns multiple values . Showing error sub query returns multiple rows.

    There is really two ways you can go about this. What it sounds to me like your dealing with is a master detail arrangement. What you probably need is two dependent reports where you pass a selected value from one report to a page item then key off that value for the 2nd report's query.
    Otherwise you could move the sub-query into the from portion of your master query and just pick the fields. This would then join the main query on the sub-query. At that point if you set your fields up correctly, you could use APEX grouping to group the results together and remove extra rows of data.

Maybe you are looking for