GROUP by equal values

I have data
Type, Month, Amount
=========
4, 1, 43333.33333
4, 2, 43333.33333
4, 3, 43333.33333
8, 5, 16000
8, 6, 16000
8, 7, 16000
8, 8, 16000
4, 2, 100
4, 3, 100and I want to group and SUM() equal amounts and find MIN(month) and MAX(month), so the output should look like
Type, MIN(month), MAX(month), SUM(amount)
=========
4, 1, 3, 130000
8, 5, 8, 64000
4, 2, 3, 200How is it possible?

Hi,
964656 wrote:
I have data
Month, Amount
=========
1, 43333.33333
2, 43333.33333
3, 43333.33333
5, 16000
6, 16000
7, 16000
8, 16000and I want to group and SUM() equal amounts and find MIN(month) and MAX(month), so the output should look like
MIN(month), MAX(month), SUM(amount)
=========
1, 3, 130000
5, 8, 64000How is it possible?You practially coded the whole thing already:
SELECT       MIN (month)     AS min_month
,       MAX (month)     AS max_month
,       SUM (amount)     AS sum_amount
FROM       table_x
GROUP BY  amount
I hope this answers your question.
If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all tables involved, and also post the results you want from that data.
Point out a few places where the query above is giving the wrong results, and explain, using specific examples, how you get those results from that data in those places.
Always say which version of Oracle you're using (e.g., 11.2.0.2.0).
See the forum FAQ {message:id=9360002}
You'll get better answers faster if you always supply this information whenever you post a question.

Similar Messages

  • Change "to equal" to "to be greater than" in Wait for Field to equal Value"

    In Sharepoint Designer 2010, in the workflow Action "Wait for Field to equal Value", I could change the "to equal" to "to be greater than". I can't find how to do this in SPD 2013.
    Can someone please help?
    Thank you!

    Hi
    PieterVanHeerden, is a big problem that gives us the change Microsoft . An option to mitigate this problem could be to use an additional workflow that runs whenever the item is updated . Workflow evaluate the condition that you need and when it is Ok, updates
    the value of a field used as flag called eg " Control_Hora_Inicio_Completo " with " true " value.
    In your current workflow you should modify the condition for the WorkflowF stops until the Control_Hora_Inicio_Completo field equal to " True " when it meets the Workflow continue and you're sure you have entered a value , whatever that is .
    I hope you can try and you work.
    Greetings from Argentina .
    Maxi
    Msorli

  • Sorting and Grouping by multi-value Choice columns - any options?

    I found out the hard way that SharePoint doesn't support sorting or grouping lists by Choice columns that are set to "Allow Multiple Values." I'm stunned by this missing capability, and my project has come to a complete halt without it. It's like Microsoft only implemented hafl the feature -- you can put data in, but then you can't do anything with it. You can't even use the column in a formula in another column, so you can't parse it.
    I'm not posting just to gripe though. Does anyone have any suggestions for alternatives? What do you do when you need to let people make multiple selections, and then you want to sort or group by those values? Are there any add-on products that allow this? At this point my only option seems to be to not allow multiple choices, but that's taking away a rather significant feature.
    Thanks for any ideas,
    Steve

    Hi Paul,
    Thank you for the reply and the additional questions. For my situation I want to use the multi-value choice to indicate a "belongs to" relationship, as in "this item belongs to projectA, projectB, and project C. Because there are more than 10 projects, I didn't want to create a separate Yes/No checkbox for each one.
    For viewing the information, I'm looking primarily for a "group by" function.  So if an item belongs to projectA, projectB, and projectC, it would appear three times, once under the grouping for each project. What I don't want is for a row that only belongs to projectA to be grouped separately from a row that belongs to both projectA and projectB. I want to see all the rows that belong to projectA grouped together, regardless of whether they also belong to other projects.
    I'll look into using a grid control, but if you have any other suggestions I'll certainly listen.
    Steve

  • Group Asset  Takeover Value

    Dear,
    Is there any table entry for group asset takeover value ?..
    When i am using AS82 for creating group asset after that click on Takeover value then that field comes in grayed..
    Regards,
    Kaushal Shah

    Hi,
    Check out the depreciation area screen layout and not asset master screen layout. Check out your Configuration fro group assets at the depreciation area level.
    Thanks,
    Sujai

  • Record group/list of values question

    Is it possible to assign one record group/list of values to multiple data items on a canves? If so, how is it done.
    Thanks

    Thanks for the replies..
    What I have is this... I have a db record with 3 currency code fields, three different types of codes, displayed on the canvas. When the user mouse's over to any of the currency code fields, I wanted the lov to pop up and the user pick one of the selections. The lov has 2 columns, country and currency
    Ex: France | Euro
    U.S. | Dol
    I built this as a static record group. If I'm in the second currency code field and pick a value, the first currency code field gets overlayed with the new value.

  • FAQ: Why does my layer (camera) move back and forth between keyframes of equal value?

    In some cases, the Auto Bezier spatial interpolation for Position keyframes can cause undesired back-and-forth (boomerang) motion between two keyframes with equal values. In such a case, you can change the earlier keyframe to use Hold interpolation or change both keyframes to use Linear interpolation.
    To change the default to linear interpolation, choose Edit > Preferences > General (Windows) or After Effects > Preferences > General (Mac OS), and select Default Spatial Interpolation To Linear. Changing the preference setting does not affect keyframes that already exist or new keyframes on properties for which keyframes already exist.
    For more information, including links to some video tutorials that demonstrate this problem and its solutions, see the "Controlling change with interploation" section of After Effects Help.

    In some cases, the Auto Bezier spatial interpolation for Position keyframes can cause undesired back-and-forth (boomerang) motion between two keyframes with equal values. In such a case, you can change the earlier keyframe to use Hold interpolation or change both keyframes to use Linear interpolation.
    To change the default to linear interpolation, choose Edit > Preferences > General (Windows) or After Effects > Preferences > General (Mac OS), and select Default Spatial Interpolation To Linear. Changing the preference setting does not affect keyframes that already exist or new keyframes on properties for which keyframes already exist.
    For more information, including links to some video tutorials that demonstrate this problem and its solutions, see the "Controlling change with interploation" section of After Effects Help.

  • Group Equal Values

    Was just curious if there was a more efficient way to get the same functionality, maybe something without the reshaping of an array on every loop iteration.
    CLA, LabVIEW Versions 2010-2013
    Attachments:
    groupLikeValues.png ‏31 KB

    I think this is sort of where Tst was heading.  Not completely sure.  But instead of reshaping the array to make it smaller, set the N on the FOR loop so it only iterates over the first N samples.  It took about a third of the time for me.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines
    Attachments:
    Group Equal.png ‏69 KB

  • Group by- Max values+equal values

    Hi Experts,
    I am looking for a query where i can group the data accordingly and exclude the rows which i don't need.please help to arrive this.
    i have the data like this in my table
    Cust_id type count
    10 abc 19
    10 abcde 19
    10 abcde 8
    20 e 8
    20 u 4
    30 f 30
    I need the out put like this
    Cust_id type count
    10 abc 19
    10 abcde 19
    20 e 8
    30 f 30
    Thanks
    Bharat

    This?
    SQL>  with abc as
      2   (
      3   select 10 Cust_id,'abc' type,19 cnt from dual union all
      4   select 10, 'abcde', 19 cnt from dual union all
      5   select 10, 'abcde', 8 cnt from dual union all
      6   select 20, 'e', 8 cnt from dual union all
      7   select 20, 'u', 4 cnt from dual union all
      8   select 30, 'f', 30 cnt from dual
      9   )
    10   select cust_id,type,cnt
    11   from
    12   (
    13     select cust_id,type,cnt,
    14            count(*) over(PARTITION BY cust_id,cnt) cnt1
    15     from
    16     (
    17       select cust_id,type,cnt,
    18              rank() over(PARTITION BY cust_id ORDER by cnt DESC) rn
    19       from abc
    20     )
    21     where rn = 1
    22   )
    23   where cnt1 = 1;
       CUST_ID TYPE         CNT
            20 e              8
            30 f             30

  • Need help - Hide row of a recursive grouping if textbox value is empty

    Hard to explain, but I will do my best.
    I have a simple report that has a resource (accounting) recursive grouping.  The group and the recursion is working correctly.  The only dollar values I have to display are at the lowest level of the hierarchy so instead of having a simple SUM("POSTED_TOTAL_AMT")
    field to show the rollup totals I did the following =Sum(Fields!POSTED_TOTAL_AMT.Value, "TREE_NODE", Recursive).
    TREE   NODE
    POSTED   TOTAL AMT
    ALL_RESOURCES
    24163945.66
    BANK
    BENALL
    7027062.56
    BENWL
    3490587.96
    BENFT
    279969.6
    BENLD
    3210618.36
    COMAB
    1357934.08
    INCWL
    2178540.52
    CASH_FLOW
    CHRTY
    COGS-ENS
    Everything I have read shows you how to hide a row based on a dataset field but I need to hide the row based on the textbox expression.  For reference here is the expression for the values showing on the report: =Sum(Fields!POSTED_TOTAL_AMT.Value, "TREE_NODE",
    Recursive)
    I added this into the row visibility: =iif(IsNothing(Fields!POSTED_TOTAL_AMT2.Value),True,False)
    But when I run the report I get the following error:
    System.Web.Services.Protocols.SoapException: The Hidden expression for the grouping ‘TREE_NODE’ refers to the field ‘POSTED_TOTAL_AMT2’.  Report item expressions can only refer to fields within the current dataset scope or, if inside an aggregate, the
    specified dataset scope. Letters in the names of fields must use the correct case.

    Hi BlackHills_SD,
    According to your description, when you use the iif expression to set visibility of the row, you got the error message.
    When we write expressions, we will find that the term scope is used in multiple contexts. Scope can specify the data to use for evaluating an expression, the set of text boxes on a rendered page, the set of report items that can be shown or hidden based
    on a toggle. It seems that POSTED_TOTAL_AMT2 is not in the same dataset as TREE_NODE. We can refer to the following steps to troubleshoot the problem:
    Right-click the report and click Insert to add a text box.
    Right-click inside of the text box, then click Expression.
    Click Datasets, click First(POSTED_TOTAL_AMT2), scope of POSTED_TOTAL_AMT2 will be listed.
    For more information about Understanding Expression Scope, please refer to the following document:
    https://technet.microsoft.com/en-us/library/dd255256%28v=sql.105%29.aspx?f=255&MSPPError=-2147217396
    If you have any more questions, please feel free to ask.
    Thanks,
    Wendy Fu
    Wendy Fu
    TechNet Community Support

  • How to read Group ID from Value Mapping Context in Cache Monitoring ?

    Hi friends,
        In RWB --> Cache Monitoring --> Integration Server (Java) -> (Search for Value Mapping Groups) in this each item is identified by Value Mapping Group (GroupID, Context, Identifier/Agency, Identifier/Scheme). Either we create Value Mapping Table in ID or replicate value mapping data directly from text file/SAP table etc., in run time cache, data will be identified in this manner.
        Now, our requirement is to delete a record the Cache for a particular context. Two operations provided by XI one is 'Delete' and another one is 'DeleteGroup'. When we use either of this, we should know GroupID. Suppose, I replicated some large amount of data from my text file in Runtime Cache. Value Mapping Table is like that IN --> India, US --> USA, AU --> Australia, EG --> Egypt. Now, I am required to write a program to get the input country code from user which is going to delete in the value mapping table like IN/AU....  For this, what logic we should follow in the program is, First we scan the value mapping table and find the record (country code)  which is match with the input. Then find the GUID value for this record. Now we use the DeleteGroup Operation and pass this GUID and then delete the record.
        So, in essence, how to read the GUID from value mapping context.
        Friends, Kindly help me to do this.
    Thanks in advance.
    Jegatheeswaran P.

    Did you get the way to read group id?

  • Grouping and sum values in XI

    Hello,
    I 'm working with invoice and I have this source structure as XI input:
    Invoice
    -- |....
    -- |....
    -- |Item1
    |taxcode=01
    |Amount=12
    --|Item2
    |taxcode=08
    |Amount=10
    --|Item3
    |taxcode=01
    |Amount=24
    Now my scope is to map these fields to the IDOC segment E1EDP04 grouping by taxcode (MWSKZ taxcode)and putting the sum of the group amount (MWSBT amount).
    IDOC:
    --|...
    --|...
    --|E1EDP01
    |...
    |...
    |EIEDP04
    |MWSKZ=01
    |MWSBT=36
    |...
    --|E1EDP01
    |...
    |...
    |EIEDP04
    |MWSKZ=08
    |MWSBT=10
    |...
    How can I group by a field in XI?
    Thank you
    Corrado

    Hi Corrado,
    If You want to do it in graphical mapping then I will do it this way:
    1. sort by taxcode
    (taxcode) --> split by value (valuechanged) --> formatByExample (Amount, and splitted value) --> sum(amount) --> MWSBT
    I can send u a screenshot of something similar if u need.
    best regards
    Dawid

  • Group based on value range and order with in group

    Hi All,
    I have a scenario like to group record set based on a value set.
    Example.
    Table data_table has 10 columns of which one column grouping_col can have value from 10 - 100
    i have to retreive a report with multiple order by clause with a precondition that
    record having grouping_col having 10-50 should be processed first then,
    record having grouping_col having 50-60 should be processed next and then so on untill 100.
    Is there a way to do this without union funcitonality.

    Please read the SQL and PL/SQL FAQ:
    SQL and PL/SQL FAQ
    especially the second question regarding how to post a question on the forums.

  • How to generate a report group by column value

    I have a table with five columns:
    c1, c2, c3, c4, count.
    I want to generate a report like this
    Total
    c1, c2
    c3, c4
    such as the values inside the table are:
    a1 b1 cc dd 2
    a1 b1 ee ff 3
    a1 b1 gg hh 4
    a1 b2 jj kk 3
    a1 b2 ll mm 4
    a1 b2 nn oo 2
    a3 b3 pp qq 3
    a3 b3 rr ss 4
    the report will be like:
    a1-b1
      cc-dd 2
      ee-ff 3
      gg-hh 4
    Total for a1-b1 9
    a1-b2
      jj-kk 3
      ll-mm 4
      nn-oo 2
    Total for a1-b2 9
    a3-b3
      pp-qq 3
      rr-ss 4
    Total for a3-b3 7
    What is the best way to achieve this?
    Thanks.
    Jen

    Hi Jen,
    Personnaly I would use a PL/SQL region and use MOD_PLSQL (htp.p) to create such a special layout, but then again you should know how to do it.
    Another way would be to create a select statement in which you select the lines you want:
    select c1||'-'||c2 key1, 0 key2, 'category '||c1||'-'||c2 , null count from table
    union
    select c1||'-'||c2, rownum, rpad(' ',5)||c3||'-'||c4, count from table
    union
    select c1||'-'||c2, count(*)+1, 'Total for cat. '||c1||'-'||c2 , sum(count)
    from table group by c1||'-'||c2, 'Total for cat. '||c1||'-'||c2
    union
    select c1||'-'||c2, count(*)+2, ' ',null from table group by c1||'-'||c2 /* empty line */
    order by 1, 2
    You can base a normal report on this.
    good luck,
    Dik

  • Payscale group and levels values are not appearing in IT0008

    Hi Friends,
    I craeted Payscale group & Level in V_T510. Eventhough these values are not coming as F4 (drop down)values in IT0008.
    Pls adivice where I have missed the configuration.
    Thanks

    Hi..
    ESG/CAP and and its grouping in V-t510 have already been maintained. however still it is not coming as drop down values.
    Pls suggest to resolve.
    Thanks

  • How to Limit the Grouped(through Bins) values in Pivot View

    Hi All,
    we have a column category which contains operational,staffing and allocation categories.
    in our requirement we need to group operational and staffing as group1 and the allocations as the other group2.i have grouped this using bins.
    our requirement is group1 should dispaly in one pivot view and group2 values should display in another pivot view.
    Could any one please suggest on this.
    NOTE: I have tried this with new calculated item option in pivot view but its unable to display character values.
    Thank You,
    Suhasini.
    Edited by: user10920790 on Nov 17, 2009 4:48 AM

    I think the issue here is that you have bins 1,2,3 but you want to see the values displayed, not 1,2,3?
    Try adding the same column again, use them next to each other in the pivot table, hide the one with the bins, what you should get is a prent and child type structure where the values are group according to the 1 2 3 in the first column.
    I htink the only way to get three separate tables would be to duplicate the query 3 times, filtering the bins column by 1 then 2 etc and displaying all three tables one below the other. Alternatively, you could try putting the bins column in the section header of the pivot table to see if that splits the tables by 1 2 3 .
    Sorry if this is a bit long winded, it's worth playing around with it though.
    regards
    Ed

Maybe you are looking for

  • Request for proper information and to refuse to help when it's missing

    On behalf of many of us volunteers who are getting tired of guessing the environment of those who are asking for help, I hereby ASK ALL VOLUNTEERS TO STOP RESPONDING TO REQUESTS FOR TECHNICAL ASSISTANCE THAT DO NOT PROVIDE SUFFICIENT INFORMATION In g

  • Follow-up question about forms and SharePoint Online

    I asked a question about life after InfoPath earlier, and got a good answer: http://social.technet.microsoft.com/Forums/sharepoint/en-US/fb23b3d9-8a09-4267-aab5-09929f6a3082/life-after-infopath-seeking-advice After looking at all of the limitations o

  • ORA-06502: PL/SQL: numeric or value error: Bulk bind: Error in define

    Hi All, Getting aforesaid error while executing a procedure. I have a procedure which takes 7 paramneters and have 13 IN OUT parameters. all the IN OUT parameters are PLSQL tables of number and varchar2. I Have checked there are no not null columns t

  • Trouble with RMI codebase

    Hi, i've created a file transfer application via RMI, it work very well, i can transfer file longer than 1 GB without any problem. But when i copy my project with all classes to another directory, it doesn't work. I'm sure that the trouble is in the

  • Problems displaying records

    I would like to display multiple records on a form. The form is set to display 20 records at a time. When I run the query it does just that except it displays the records one at a time in the space provided for the topmost record. It gives me a frm-4