GROUP BY ROLLUP with Grouped Category Subtotals

Hi,
I need the categories to have group totals like the example below. Notice that California has it's own category subtotals then a grand total.
I could do this with unions, a row type column, and sorting, but that would mean reading the entire table for each total snd subtotal.
Any suggestions?
Thank You in Advance for Your Help,
Lou
My Data
STATE CITY CATEGORY NBR
California     Los Angeles     AA     1
California     Los Angeles     BB      2
California     Los Angeles     CC     3
California     San Diego      AA      4
California     San Diego BB     5
California     San Diego     CC     6
California     San Francisco     AA     7
California     San Francisco     BB     8
California     San Francisco     CC     9
Desired Result
STATE CITY CATEGORY NBR
California     Los Angeles     AA      1
California     Los Angeles     BB     2
California     Los Angeles     CC     3
California     Los Angeles          6
California     San Diego     AA     4
California     San Diego     BB     5
California     San Diego     CC     6
California     San Diego          16
California     San Francisco     AA     7
California     San Francisco     BB     8
California     San Francisco     CC     9
California     San Francisco          24
California          AA     12
California          BB     15
California          CC     18
Grand Total               45

My bad, that would be a cube then
SQL> with t as (select 'California' state, 'Los Angeles' city, 'AA' categ, 1 nbr from dual
  2  union all select 'California' state, 'Los Angeles' city, 'BB' categ, 2 nbr from dual
  3  union all select 'California' state, 'Los Angeles' city, 'CC' categ, 3 nbr from dual
  4  union all select 'California' state, 'San Diego' city, 'AA' categ, 4 nbr from dual
  5  union all select 'California' state, 'San Diego' city, 'BB' categ, 5 nbr from dual
  6  union all select 'California' state, 'San Diego' city, 'CC' categ, 6 nbr from dual
  7  union all select 'California' state, 'San Francisco' city, 'AA' categ, 7 nbr from dual
  8  union all select 'California' state, 'San Francisco' city, 'BB' categ, 8 nbr from dual
  9  union all select 'California' state, 'San Francisco' city, 'CC' categ, 9 nbr from dual)
10  select state,
11         city,
12         categ,
13         sum(nbr) total
14   from t
15   group by cube(state, city, categ)
16  having (grouping(city) = 1 and grouping(state) = 0)
17  or (grouping(categ) = 0 and grouping(city) = 0 and grouping(state) = 0)
18  order by state, city, categ
19  /
STATE      CITY          CA      TOTAL
California Los Angeles   AA          1
California Los Angeles   BB          2
California Los Angeles   CC          3
California San Diego     AA          4
California San Diego     BB          5
California San Diego     CC          6
California San Francisco AA          7
California San Francisco BB          8
California San Francisco CC          9
California               AA         12
California               BB         15
STATE      CITY          CA      TOTAL
California               CC         18
California                          45
13 linhas selecionadas.
SQL> You can play around with the having clause and groupings and select the rows as needed.
Regards,
Francisco.
Edited by: fsitja on Mar 24, 2009 6:11 PM
Edited by: fsitja on Mar 24, 2009 6:14 PM

Similar Messages

  • Setup group category & setup group Key.

    Dear Friends,
    I am facing some problem in setup group category... Please check this scenario and let me know...if anybody is having any idea about this...
    My scenario is: I am having a single work center... on which I  can do some machining activity.This WC is used in 100 material routings. but all my 100 materials are grouped into 5 categories. based on the dia... for example 100-120 dia one group 121-140 dia another group like that. If my two successive materials are belong to same group..then.. I donot have any setup time. if my two success materials scheduled on that machine are not belong to same group...then I am having 5 hrs of setup time.
    so here setup time I can not mention in the routing...
    this can be achieved by setup group and setup group key...and through capacity leveling... we can insert this setup time as per the matrix... in the matrix we need to define the setup times between two different groups..
    And here the setup time is almost equal to machining time of one material. max.. they can do 3 materials machining only.. if there is no setup in a day of 16 hrs working. So manageement wants to minimize setup time... so grouping of the materials should be based on the Dia... this is the requirement.
    I hope u understood my requirement...
    Actually I maintained all the setup group categories, setup group keys in the routing and I maintained setup matrix also...
    But during the finite scheduling through Capacity leveling I am not able to consider the setup time in the production order.... This is the problem I am facing... If anybody is having any idea...please share with me..
    Regards,
    Surya.

    Hi Suryanarayana,
    I see that you have defined setup type and setup group keys and also setup matrix.
    Please check the following under SPRO -> CRP -> Capacity leveling and extended evaluation -> Strategy -> Define strategy profile. There is a standard strategy profile to optimize setup times, which is SAPSFCT005 (Fin.sched.for./disp.acc. to setup group). Check the settings under this profile especially the check box "dispatch at best time for set up" to see if it works.
    Best of luck,
    Sharabh

  • Add new instrument group/category?

    I'm working on composing for a video game project, and for the music I've set up a bunch of my own instrument presets. I'd like to create a new group/category for these presets. For example, there is "Bass", "Drum Kits", "Guitars", etc. I'd like one titled "The Game" for example. That way I don't have to jump around between categories to find/edit the game's instruments. It would save a LOT of time. How do I go about doing this?
    Thanks for any advice!!

    Go into the folder HD/Library/Application Support/GarageBand/Instrument Library/Track Settings/Software. There you see the folder with the categories. (Or in the respective folder in your User directory.)
    You should be able to create new folders there and put your self-created .cst files into them. Be careful with everything you do in the Instrument Library - it is not meant to be maniputlated manually, so you might confuse GB!

  • Entering Product Group / Category at the Lead Creation Stage

    Hi
    Our Client requires to capture the Product Group / Category at the Lead Creation Level.
    At the lead creation level the sales engineer is not exactly aware of the product pricely which the customer wants to buy but knew which Product Group / Category the customer is interested in. So is there any way to capture the Product Group / Product Category at the Lead Creation Level.
    Regards
    Punit Kapoor

    1. Use TCode 0VVW for creating a Z Item Usage, say, ZPO1
    2. Do an item Cat determination in VOV4, as
    Sales Doc type
    Item Cat Group
    Usage
    Item Category
    OR -
    NORM -
    ZPO1 -
    TAB
    3. Maintain Customer Materials Info Record by using VD51.
    In item screen for Cust-Mat combination maintain Item usage
    Regards
    JP

  • Preq with Item category U

    Hello,
    Could anyone of you please help in config of creating preq with item category "U" through MRP run.
    I also want to assign Plant as source of supply automatically once the Purchase requisition is created.
    Thanks
    Karan

    Hi ,
    1) goto OMD9
    2)give ur plant no. and specila procurement key 45
    3)under specila procurement tab -> in plant field u specify your supplying plant no  --> in stk transfer field specify 1
    4)now set a vendor no. for the supplying plant ---
                       a)to do so craete a vendor through XK01 , account group 0007 , give the plant no for which MRP is carried out
                       b) In purchasing view -- goto extras -- add purchasing data --in plant field give the supplying plant no.
    5)In the material master record -> MRP 2 view maintain the special procurement key 45
    6) now do the mrp run
    7) But if quota arrangement is used then it gives the priority to that quota arrangement . So either you remove the quota arrangement or specify maximum limt.
    Regards,
    Anupam
    Edited by: Anupam Halder on Jul 13, 2009 10:01 AM

  • Intercompany transfer for material with item category Erla

    Hi,
    I have a typical requirement.
    I am creating a value pack(finish good) with item category mainatined as ERLA(while mat master creation) which consistes of 2 items.
    I have maintained a BOM for this value pack(finished material).
    Since ERLA is maintained,I can explode BOM in Sales Order creation(correct me if I am wrong)
    This is okay for sales cycle.
    I have following requirement
    I want to do a Intecompany stock transfer of this value pack(i.e. finish good) with doc type NB.
    The problem in this is that it gives error while creating outbound delivery stating some entries missing in table (do not exactly remember)for NLCC/DOGN.. something like that.
    If anyone has done this type of scenario earlier then request you to send me the configuration settings required to be done in terms of Item category/Delievry combination etc etc .
    This is quite urgent for me.
    If there is any different way to map this Intecompany Stock Transfer of Material (with Item category maintained as ERLA) then please let me know.
    Thanks in advance.
    Regards,
    manOO

    Hi
    You maintain "Item category group" NORM in the Sales org 2 tab, this is used for sales organisation and distribution channel for Outboumd delivery.
    The "General Item category group" does not refer to the Sales organisation and distribution channel, this is used for Inbound delivery.
    In can create the material master in MM01, specify the "Material type" and "Industry sector" .
    For, Item category determination in VOV4, you need to assign like this as below,
    Sales doc type + Item category group + usage + Item category of higher level item = Item category.
    Item category determination for free item,
    OR + NORM + FREE + TAN = TANN.
    As beacuse you are giving the normal material as free, therefore you must give the indication to the system to use it as free material by specifying the usage as "FREE".

  • Sale order with item category TAN not getting displayed in md04

    Hi,
    We have a sale order with item category TAN, Schedule line category CP, MRP type ND and availability check as 07. This is not getting reflected in md04. But item category TAB gets displayed under the PR number.
    Please let me know what checks to be made or changes to be done for the sale order with item category TAN to get displayed in md04 screen
    Thanks & Regards

    Hi all,
    I changed the MRP type to PD, and from the next sale order, line item onwards, it was getting displayed in md04 screen. The already created one anyway dint get reflected. So I had to delete the line item and create a new one.
    Thanks all for the help
    Regards,
    Jegashree

  • BOM with Item Category T

    Hi friends,
    The issue my user is having is that he has created a subcontracting PO ...and later while issuing thro MB1b 541... the system throws an error... PO HAS NO ITEMS..
    But PO has a BOM exploded ...when i check it has item category T instead of an L... By the time i could check CS03, the user has deleted the BOM .,so i suggested to create a new one with item category L...The issue got resolved.
    But my doubt is how this item category T has appeared in the BOM, since when i try creating a BOM with T i cannot enter matl code but my BOM which had popped in the PO had all details with matl code, desc , qty  and item category as T..
    Pls kindly advise and help me understand..
    Thanks
    nandu

    When creating your material BOM with Item category T, do not enter the material number.
    Only enter decripiton qty. and uom. This should allow you to create the BOM. You would then see this BOM in your Sub-Contract PO. I don't think it was possible you saw the material item in the BOM from your original T category items, as this would not be allowed per standard functionality, as you noted when trying to recreate the incorrect BOM.

  • To fill in the material number with item category u201CBu201D for Framework Order.

    The use of framework orders (also referred to as blanket purchase orders)  enables you to procure a variety of materials or services from a vendor up to a predefined maximum value (the value limit).
    Instead of a specific delivery date, you specify a validity period for the order.
    Goods receipts or the entry and acceptance of services performed are not necessary in the case of a framework PO and limit items.
    The invoices are posted directly with reference to the purchase order, provided that the specified value limit is not exceeded. When the value limit of the PO is reached, or the validity period is exceeded, the system issues a warning message. It is possible to book the invoices, but these are blocked for payment.
    During the phase of service performance, the cumulative u201Cactual" values (for the services actually performed) are continually updated in the underlying purchase. This enables you to monitor the progress of a procurement project on an ongoing basis. By comparing the "actual" value with the total value, you can always obtain an overview of the degree to which a budget for unplanned services or materials has been exhausted (i.e. see whether predefined limits have been reached or nearly reached).
    So with the Framework Order type (FO) and item category u201CBu201D you get the error that it is not allowed to fill in the material number with item category u201CBu201D.
    Please suggest me the possible solution to fill in the material number with item category u201CBu201D for Framework Order.
    Best Regards,
    Harisha

    The Framework order type is specialy defined for lesser value procurements (ex: stationeries, cleaning services ....) which are all not worthy to create Material Master at all.
    If you are very sure to fill the Material number, then proceed with some other document type.
    In what circumstances you want to put material number in FO order?
    Karthi.

  • Purchase requisition with Item Category – L creation via Maintenance orders (Plant Maintenance)

    Hi Guru’s,
    I have a scenario where purchase requisition with Item Category – L (subcontract External) for Repair items (Storeroom Process) need to get generated with Item category-L.This requirement is to MAP in my system.
    I am aware that purchase requisition can be created with reference to maintenance orders.
    Can anybody through some light on the integration between PM and MM.
    If creation of purchase requisition is possible via maintenance orders then please explain me with detailed steps both configurations and master data so that I can able to replicate the same as per business requirement.
    I look forward to the expert’s response.
    Regards,
    Kumar

    Hi Kumar.S
    You have to installed DIMP 6.0, and activated the business function Refurbishment and Subcontracting (LOG_EAM_ROTSUB) and Serial Numbers in Purchasing (LOG_MM_SERNO) .
    Please check the below link:
    http://scn.sap.com/thread/1956895
    Hope it will help you to resolve your issue.
    Regards,
    Ritesh

  • MD04: Unable to see Purchase Orders with Item Category S

    Hi,
    Whenever we create Purchase Orders with Item Category S (3rd party), they are not visible in MD04 Stock Requirements list.
    Is there anyway we can get the Item category S Orders to be displayed in the MD04 list?

    Hi,
    I am unable to see Third party POs with open quantity also.
    If I create a PO with blank item category (i,e to stock, it will show in MD04)
    but if i create PO with item category S (it does not show in MD04)
    Can you suggest how we can get item category S POs to be displayed in MD04

  • Delete purchase requisition with item category Subcontracting

    Hi all,
    I need to delete a purchase requisition with item category = L (subcontracting).
    I am using already BAPI_REQUISITION_DELETE to delete other purchase requisitions but for the subcontracting it doest not work. In fact in the BAPI code you can see:
    Requisitions with dependent reservations won't be processed
        IF xeban-pstyp EQ 3 AND xeban-rsnum NE space.
    So I am looking for other BAPI but I don't find any to delete this kind of requisitions. Do you know any way to do that or I have to do a batch input?
    Thx,
    Manel

    Hi Manel,
    I am using BAPI_PO_CHANGE to set EBAN_EBAKZ, however in most of the cases error thrown as "Instance PO Number of object type  could not be changed".
    Could you please help on this?
    Thanks,
    Murali

  • Create BOM with item category L

    Hi,
    I am facing an issue while going to create BOM with item category L.
    System shows material type can not be used with item category L for that particular plant.
    Please help...
    Thanks,
    Rampreet Jaiswal
    Edited by: Csaba Szommer on Jan 11, 2012 12:21 PM

    Hi,
    Its also maintained * for header material.
    Guys we have already checked OS14 and OS24 at first. but it is allowed for header and item.
    regards,
    Solomon

  • " SYSTEM ERROR" with ERROR CATEGORY: Message and ERROR ID : GENERAL

    HI all
    I m doing JDBC -> XI -> SOAP -> XI -> FILE ( XML) scenario .I have implemented it using  BPM .
    But ,In MONI , i am getting a "SYSTEM ERROR " with "ERROR CATEGORY : MESSAGE" and "ERROR ID : GENERAL" .and 
    One thing more is there my all adapters are active (JDBC,FILE) in runtime workbench but SOAP adapters i am not able to see it there as its services are not defined in there .Is this problem is because SOAP adapters are not defined in runtime workbench ?

    Hi Colin
    I are using SP 3.0
    I have checked the Communication channel monitoring and Adapter monitering also but in mine case when i want to see the SOAP adapter in adapter monitoring , the SOAP ICON is disabled there ,so i am not able to see whats the status of my SOAP adapter i have used in my scenario
    Thanks and Regards
    Abhishek

  • Inventory problem for material with valuation category X

    Hi!
    During annual inventory, I found material in a storage location that doesn't exist in SAP as material master.
    I have created the material, managed in batches and valuation category X.
    I have created a batch with MSC1N and now I am trying to create an inventory document to put this material on stock; but when I am trying to create the inventory document with MI01 or MI31, the system is telling me :
    "Batch  0000043183   does not contain a valuation type
    Message no. M7045
    Diagnosis
    The material is subject to split valuation, but the batch entered has not been assigned to a valuation type.
    System Response
    Any transaction/event that has the effect of changing the stock balance will be rejected for this batch.
    Procedure
    Contact your system administrator.
    If you are authorized to do so, do you wish to check the valuation category in the material master record?
    Do you want to display the batch?"
    Now, I don't know exactly what can I do to be able to create the inventory document.
    Any ideas.....
    Thanks

    Since you have created a material master with valuation category that means the system is taking that material either as split valuated or to-be split valuated...the reason of this error you will find out if you go to MSC2N with material-batch & plant you will find in the Basic data 1 tab that Valuation type field is mandatory...so either you have to split valuate the item further and then enter the same valuation type in MSC2N or otherwise if you not still done any transaction with the material master then remove the valuation category from the material master
    Regards,
    Indranil

Maybe you are looking for

  • Unable to download pdf file in windows 8.1

    After upgrading to windows 8.1, i have been unable to download pdf files sent via yahoo email, IE11 and Adobe Reader 11.  Did not have this problem before with windows 8.  I click on the pdf attachment, NOrton says that the file is safe but nothing h

  • Acrobat 7.0 repair download

    I have Adobe Acrobat 7.0.  I wanted to de-activate it from Vista to go back to XP.  It would not deactivate, but I followed the message to go to the Adobe website to download a version which does not require activation.  I downloaded the file, ran it

  • Windows 7 service pack 2 and Firfox are now not compatable? Is there a fix?

    Windows 7 updated today. Firefox no longer works. States not compatible. Uninstalled and reloaded. Still no go. Is there a fix for this?

  • Translation error at update process (German)

    Hi, during the update progress of Flash Player in German (on Windows 7), the text is translated wrong. Instead of "Installation wird zurzeit ausführt" it should be "Installation wird zurzeit ausgeführt". Kind regards Domar

  • Enet IP communication with 1794-AENT module

    Has anyone had success with communicating with the Rockwell 1794-AENT/B ethernet modules?  I have one of the Flex I/O ethernet interface modules with two 8 port analog in modules connected.  I can read the 1794/AENT module information, using the ENET