Rollup Query

I have written the following query for summarizing tablespace usage :
SELECT DECODE(GROUPING(a.file_name), 1, NULL,a.tablespace_name) AS "TABLESPACE",
DECODE(GROUPING(a.file_name), 1 ,'TOTAL', a.file_name) AS "DATAFILE",
ROUND(SUM(a.bytes)/1024/1024, 2) AS "SIZE(MB)",
NVL(ROUND(SUM(b.bytes)/1024/1204, 2), 0) AS "FREE(MB)",
100-(ROUND(100*(NVL(ROUND(sum(b.bytes)/1024/1204, 2), 0) / ROUND(SUM(a.bytes)/1024/1024, 2)),2)) AS "%USED"
FROM dba_data_files a,
dba_free_space b
WHERE b.file_id (+)=a.file_id
AND a.tablespace_name NOT IN (
SELECT UPPER(value)
                         FROM v$parameter where
                         LOWER(name) ='undo_tablespace'
GROUP BY a.tablespace_name, ROLLUP (a.file_name);
I would like to added the autoextensible column from dba_data_files to show whether or not the datafile can autoextend. I tried doing it like this:
SELECT DECODE(GROUPING(a.file_name), 1, NULL,a.tablespace_name) AS "TABLESPACE",
DECODE(GROUPING(a.file_name), 1 ,'TOTAL', a.file_name) AS "DATAFILE",
DECODE(GROUPING(a.file_name), 1, NULL, a.autoextensible) AS "AUTOEXTEND",
ROUND(SUM(a.bytes)/1024/1024, 2) AS "SIZE(MB)",
NVL(ROUND(SUM(b.bytes)/1024/1204, 2), 0) AS "FREE(MB)",
100-(ROUND(100*(NVL(ROUND(sum(b.bytes)/1024/1204, 2), 0) / ROUND(SUM(a.bytes)/1024/1024, 2)),2)) AS "%USED"
FROM dba_data_files a,
dba_free_space b
WHERE b.file_id (+)=a.file_id
AND a.tablespace_name NOT IN (
SELECT UPPER(value)
     FROM v$parameter where
          LOWER(name) ='undo_tablespace'
GROUP BY a.tablespace_name, a.autoextensible, ROLLUP (a.file_name);
This method works fine until you have a tablespace that has both a datafile that is non-autoextend and a datafile that is autoextend. When this situation arises it messes up the ROLLUP subtotaling and shows a subtotal for the non-autoextend datafile and the autoextend datafile instead of showing a subtotal for the combined datafiles. Can anyone think of a way of displaying the autoextensible column in the query without including it in the aggregation?

Hi,
Try this code.
Regards salim.
SELECT   DECODE (GROUPING (a.file_name),
                 1, NULL,
                 a.tablespace_name
                ) AS "TABLESPACE",
         DECODE (GROUPING (a.file_name),
                 1, 'TOTAL',
                 a.file_name
                ) AS "DATAFILE",
         DECODE (GROUPING (a.file_name),
                 1, NULL,
                 a.autoextensible
                ) AS "AUTOEXTEND",
         ROUND (SUM (a.BYTES) / 1024 / 1024, 2) AS "SIZE(MB)",
         NVL (ROUND (SUM (b.BYTES) / 1024 / 1204, 2), 0) AS "FREE(MB)",
           100
         - (ROUND (  100
                   * (  NVL (ROUND (SUM (b.BYTES) / 1024 / 1204, 2), 0)
                      / ROUND (SUM (a.BYTES) / 1024 / 1024, 2)
                   2
           ) AS "%USED"
    FROM dba_data_files a, dba_free_space b
   WHERE b.file_id(+) = a.file_id
     AND a.tablespace_name NOT IN (SELECT UPPER (VALUE)
                                     FROM v$parameter
                                    WHERE LOWER (NAME) = 'undo_tablespace')
GROUP BY a.tablespace_name,  ROLLUP ((a.autoextensible,a.file_name));Remark: please put your code between                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            

Similar Messages

  • Serial Number in Rollup Query

    Hi All
    I want to create Serial Number(running number like 1,2,3...)
    in Rollup Query. But my problem is,I want to create running number all rows except for Toatl row.
    EX:
    select COMPANY,DEPT,SUM(SALARY) from emp
    GROUP BY ROLLUP(COMPANY_NAME,DEPT)
    Expected O/P :
    SL.No     COMPANY     DEPT     SALARY
    1     ABC     P     60000
    2     ABC     A     40000
         ABC          100000
    3     XYZ     P     30000
    4     XYZ     A     40000
         XYZ          70000
                   170000
    How to do the above? Help me..
    Regs
    Kumar

    SQL> create table emp (company,dept,salary)
      2  as
      3  select 'ABC', 'P', 60000 from dual union all
      4  select 'ABC', 'A', 20000 from dual union all
      5  select 'ABC', 'A', 20000 from dual union all
      6  select 'XYZ', 'P', 15000 from dual union all
      7  select 'XYZ', 'P', 15000 from dual union all
      8  select 'XYZ', 'A', 40000 from dual
      9  /
    Table created.
    SQL> select case grouping_id(company,dept)
      2         when 0 then row_number() over (order by grouping_id(company,dept),company,dept desc)
      3         end sl_no
      4       , company
      5       , dept
      6       , sum(salary)
      7    from emp
      8   group by rollup(company,dept)
      9   order by company
    10       , dept desc nulls last
    11  /
         SL_NO COM D SUM(SALARY)
             1 ABC P       60000
             2 ABC A       40000
               ABC        100000
             3 XYZ P       30000
             4 XYZ A       40000
               XYZ         70000
                          170000
    7 rows selected.Regards,
    Rob.

  • Help with Rollup Query

    I am in need of some assistance with rolling up data in a SQL query using Oracle 9i. I think that I have a "working" query, but I cannot get it to complete (ran for 4 hours before killing it). There must be a better way. Anyhow, I have a table "lcec_outage_rollup_tab2", with sample data below:
    Device Hierarchy SerialNumber Online Offline
    F9997     /B0271/F9997/          0     0
    F1928     /B0271/F9997/F1928/          0     0
    T19928     /B0271/F9997/F1928/T19928/     3966797     1     0
    T19928     /B0271/F9997/F1928/T19928/     3961826     1     0
    T19928     /B0271/F9997/F1928/T19928/     3936230     0     0
    T19928     /B0271/F9997/F1928/T19928/     3961825     1     0
    T25357     /B0271/F9997/F1928/T25357/     3961824     0     1
    T25357     /B0271/F9997/F1928/T25357/     3833846     1     0
    T30525     /B0271/F9997/F1928/T30525/     9414591     1     0
    T32276     /B0271/F9997/F1928/T32276/     9402547     1     0
    T32276     /B0271/F9997/F1928/T32276/     3966807     1     0
    T32276     /B0271/F9997/F1928/T32276/     3907898     1     0
    T33190     /B0271/F9997/F1928/T33190/     3897790     1     0
    T33190     /B0271/F9997/F1928/T33190/     3966785     0     0
    F1929     /B0271/F9997/F1929/          0     0
    T28967     /B0271/F9997/F1929/T28967/     3963806     1     0
    T28967     /B0271/F9997/F1929/T28967/     3966842     0     1
    T28967     /B0271/F9997/F1929/T28967/     9469217     0     0
    I would like a sum of the Offline and Online columns, rolled up by device. So the results would look like:
    Hierarchy Online Offline
    /B0271/F9997/     10     2
    /B0271/F9997/F1928/     9     1
    /B0271/F9997/F1928/T19928/     3     0
    /B0271/F9997/F1928/T25357/     1     1
    /B0271/F9997/F1928/T30525/     1     0
    /B0271/F9997/F1928/T32276/     3     0
    /B0271/F9997/F1928/T33190/     1     0
    /B0271/F9997/F1929/     1     1
    /B0271/F9997/F1929/T28967/     1     1
    I am working with the following query:
    select distinct hierarchy,
    (select sum(Online_Status)
    from lcec_outage_rollup_tab2 t1
    where t1.hierarchy like '%/' || t.device || '/%'
    and serialnumber > 0) online_count,
    (select sum(Offline_Status)
    from lcec_outage_rollup_tab2 t1
    where t1.hierarchy like '%/' || t.device || '/%'
    and serialnumber > 0) offline_count
    from lcec_outage_rollup_tab2 t
    There are 217,000 rows in the "lcec_outage_rollup_tab2" table. Any ideas on how to improve this query so that it runs in less than an hour? Fancy indexing? Parallelizing the query? Etc.? Thanks in advance.

    Hi,
    Use GROUP BY and a self_join, like this:
    WITH     by_hierarchy     AS
         SELECT       hierarchy
         ,       SUM (online_status)     AS online
         ,       SUM (offline)status)     AS offline
         FROM       lcec_outage_rollup_tab2
         GROUP BY  hierarchy
    SELECT       p.hierarchy
    ,       SUM (c.online)     AS online
    ,       SUM (c.offline)     AS offline
    FROM       by_hierarchy  p
    JOIN       by_hierarchy  c  ON     INSTR ( c.hierarchy
                                   , p.hierarchy
                              ) = 1
    GROUP BY  p.hierarchy
    ORDER BY  p.hierarchy
    ;If you'd care to post CREATE TABLE and INSERT statements for the sample data, then I could test this.
    INSTR, as shown above, will probably be a little faster than LIKE.

  • Has anyone used grouping sets or perhaps rollup function

    I am trying to do a rollup query ....to sum up sales based on an
    account number you would think pretty simple.....so here is the
    query I wrote
    SELECT broker_number
    account_number , ACCOUNT_NAME ,
    to_char( SUM ( FACTORY_NET_AMT ) , '9,999,999,999') sales$
    FROM broker_account_expanded
    WHERE product_level = 'BRND'
    and product_level_Code not in ( select PROD_CATEGORY_CD from
    genesis.tFIN_BRAND )
    AND PRODUCT_LEVEL_CODE = '100515'
    group by GROUPING SETS (
    ( broker_number , account_number , account_name ))
    however I am getting the following error
    SQL> /
    group by GROUPING SETS (
    ERROR at line 9:
    ORA-00933: SQL command not properly ended
    Any ideas ?
    Thank's
    Sameer Handa

    I think correct would be:
    GROUP BY ROLLUP (broker_number , account_number , account_name )

  • Tracking queries using aggregates with BW Statistics queries

    Hi,
    I am trying to find out if I can run any reports against the BW Statistics cubes to figure out what aggregates are getting called from our queries. Any advise that you can provide is greatly appreciated.
    Thanks,
    Dinesh

    Hi Dinesh,
      Check out this query
    Aggregate Rollup
    Query: 0TCT_MC11_Q0142
    check here.........also............
    http://help.sap.com/saphelp_nw70/helpdata/en/46/f9bd5b0d40537de10000000a1553f6/frameset.htm
    Regards,
    Vijay.

  • Large Fact Tables

    I have some transactional tables that are quite large. Anywhere from 1 to 3 million records. I have been doing my best to find information on the best way to deal with these and I am having some trouble. I am a little tight for time and could use a little help from others who have dealt with large datas sets before. What are some of the best ways to deal with this.
    I have tried creating database level partitions by date which didn't seem to affect the OBI performance much. If I actually create different physical tables through the ETL process for each year it helps but I would like to avoid needing to create and manage that many different mappings.
    Is the best way to do this to use the OBI caching and seed the cache after loading the data? I have even tried a few indexes and not had much luck.
    Any help is greatly appreciated and I thank everyone in advance for their time. :)

    Presuming Oracle backend database.....(you didnt say)
    Partitioning would seem a quick (and expensive $$$$) win, if you partition on date, be sure to use the same date key to perform 'partition pruning' , which is to say give the optimizer a chance to throw away all unrequired partitions before it starts going to disk. When you say 'didnt improve performance much' you need to give a partition wise join for the partitioning to become effective at query time - did you do this ? for example a dashboard prompt with a filter on week / month would help (assuming your week / month time dim column is joined on partition key)
    Is your data model a star schema ? Do you have dimension metadata in your database ? I'd be looking at Materialized views and looking for some sort of aggregate rollup query re-write whereby you queries are re-written at run time to the Mview and does not hit your fact table.
    As for caching, OBIEE caching is the last resort after you exhaust every other alternative, its not there to speed up queries and you would be hiding the problem, what when a user drills down or needs to run an ad-hoc report that is not cached ?
    I would start with understanding Oracle execution plans, review your data model (with the view on speedy data extraction) and look at what Oracle DB gives for data warehousing appliances :
    parallelism is your friend!
    star transformation,
    Mviews (table or Cube based)
    OLAP

  • Large editable tables

    I have a datatable with input fields assigned to each column. The user can edit values freely and then submit the changes for update. Because of the size of the list it appears that a huge amount of processing is required even though only a couple of rows are actually modified by the user.
    Is there a "best practices" for handling large editable tables that anyone is aware of?
    Thanks

    Presuming Oracle backend database.....(you didnt say)
    Partitioning would seem a quick (and expensive $$$$) win, if you partition on date, be sure to use the same date key to perform 'partition pruning' , which is to say give the optimizer a chance to throw away all unrequired partitions before it starts going to disk. When you say 'didnt improve performance much' you need to give a partition wise join for the partitioning to become effective at query time - did you do this ? for example a dashboard prompt with a filter on week / month would help (assuming your week / month time dim column is joined on partition key)
    Is your data model a star schema ? Do you have dimension metadata in your database ? I'd be looking at Materialized views and looking for some sort of aggregate rollup query re-write whereby you queries are re-written at run time to the Mview and does not hit your fact table.
    As for caching, OBIEE caching is the last resort after you exhaust every other alternative, its not there to speed up queries and you would be hiding the problem, what when a user drills down or needs to run an ad-hoc report that is not cached ?
    I would start with understanding Oracle execution plans, review your data model (with the view on speedy data extraction) and look at what Oracle DB gives for data warehousing appliances :
    parallelism is your friend!
    star transformation,
    Mviews (table or Cube based)
    OLAP

  • Query help - problems with ROLLUP

    I'm trying to make a query i can use for an alert, it generates sales for the past 7 days.
    This query works fine:
    SELECT
          CASE WHEN GROUPING(T0.[CardCode]) = 0
                THEN CAST (T0.[CardCode] AS CHAR(8))
                ELSE 'ALL'
          END AS Customer#,
          SUM(T0.[Max1099]) AS "Total Sales",
          SUM(T0.[GrosProfit]) AS "Gross Profit" 
    FROM OINV T0
    WHERE T0.[DocDate] >= DATEADD(dd,DATEDIFF(dd,0,GETDATE())-7,0) AND T0.[Max1099] > 0
    GROUP BY T0.[CardCode] WITH ROLLUP
    And it gives me this:
    #     Customer#*     Total Sales*     Gross Profit*     
    1     C2235              8,285.87       4,165.77            
    2     C2236           10,191.39              4,197.95            
    3     C2253                570.56               311.17          
    4     C3008           18,756.76       5,720.21            
    5     ALL                   37,804.58    14,395.10            
    Which is great. Gives me a total at the end, and substitutes "ALL" for the customer number. Lovely.
    Problem #1: I REALLY want it to give the Customer Name NEXT TO the Customer Number. But when I try to add it, i have to add it to the GROUP BY as well. Which changes the query to this:
    SELECT
          CASE WHEN GROUPING(T0.[CardCode]) = 0
                THEN CAST (T0.[CardCode] AS CHAR(8))
                ELSE 'ALL'
          END AS Customer#,    
          CardName as "Cust Name",     
          SUM(T0.[Max1099]) AS "Total Sales",
          SUM(T0.[GrosProfit]) AS "Gross Profit"
    FROM OINV T0
    WHERE T0.[DocDate] >= DATEADD(dd,DATEDIFF(dd,0,GETDATE())-7,0) AND T0.[Max1099] > 0
    GROUP BY T0.[CardCode], T0.[CardName] WITH ROLLUP
    And changes my output to THIS:
    #     Customer#     Cust Name                             Total Sales     Gross Profit     
    1     C2235             Acme Products                      8,285.87               4,165.77     
    2     C2235          (blanks blanks)                        8,285.87               4,165.77     
    3     C2236             Some Other Products             10,191.39               4,197.95     
    4     C2236          (blanks blanks blanks)            10,191.39               4,197.95     
    5     C2253             Third Customer Name             570.56                  311.17     
    6     C2253          (blanks blanks blanks)                570.56                  311.17     
    7     C3008             Fourth Customer Name       18,756.76       5,720.21     
    8     C3008          (blanks blanks blanks)                                               18,756.76       5,720.21     
    9     ALL                                                                  37,804.58     14,395.10     
    ( I have replaced actual customer names, of course, and replaces actual blanks with the word 'blanks' so it would be more legible.)
    I can't figure out a way to simply list the customer name next to the number. Instead , it gives me a summary for the CardCode and a summary for the CardName.
    I've tried combining the two into one field, on the fly, but haven't been successful.
    Problem #2 - extra credit!
    If i really want this done right, i should also have a query that pulls the same data from ORIN (Credit Memos) and do a UNION ALL, but when i do this, is simply rejects me at the word "UNION"
    any and all help appreciated, and to test this, you can just cut and past the query into SAP, it will run right there, no mods needed.
    oops. I had to change the "Not Equal" symbol to just "greater than" for "Max1099" because it was just dropping the symbol...
    Edited by: Dante Amodeo on Jan 18, 2012 6:30 PM

    Try:
    SELECT CAST (T0.CardCode AS CHAR(8)) AS Customer#,
    MAX(T0.CardName) 'Customer Name',
    SUM(T0.Max1099) AS 'Total Sales',
    SUM(T0.GrosProfit) AS 'Gross Profit'
    FROM OINV T0
    WHERE DATEDIFF(dd,T0.DocDate,GETDATE())<=7 AND T0.Max1099 > 0
    GROUP BY T0.CardCode
    UNION ALL
    SELECT 'ALL','',SUM(T0.Max1099),
    SUM(T0.GrosProfit)
    FROM OINV T0
    WHERE DATEDIFF(dd,T0.DocDate,GETDATE())<=7 AND T0.Max1099 > 0

  • Hierarchical Query with Rollup Sum (CONNECT BY with GROUP BY ROLLUP)

    Hi all,
    Imagine the following scenario: i have an ACCOUNT table which holds accounts and their hierarchy (currently 5 levels), and a BALANCE table which holds balance records for the accounts. Only CHILD accounts (level 5) have records in the BALANCE table. Simple example:
    CREATE TABLE accounts (account_code VARCHAR2(30), parent_account VARCHAR2(30), account_desc VARCHAR2(400));
    CREATE TABLE balances (account_code VARCHAR2(30), balance_amount NUMBER(18,2));
    INSERT INTO ACCOUNTS VALUES ('TOT',NULL,'Total');
    INSERT INTO ACCOUNTS VALUES ('ANA1','TOT','General Expenses');
    INSERT INTO ACCOUNTS VALUES ('4801001','ANA1','Small Expenses');
    INSERT INTO ACCOUNTS VALUES ('4801002','ANA1','Transportation');
    INSERT INTO ACCOUNTS VALUES ('ANA2','TOT','Health Expenses');
    INSERT INTO ACCOUNTS VALUES ('4802001','ANA2','Healthcare');
    INSERT INTO ACCOUNTS VALUES ('4802002','ANA2','Facilities');
    INSERT INTO BALANCES VALUES ('4801001', 2000);
    INSERT INTO BALANCES VALUES ('4801002', 1000);
    INSERT INTO BALANCES VALUES ('4802001', 3000);
    INSERT INTO BALANCES VALUES ('4802002', 4000);What i need in this scenario is to run a hierarchical query, where for each node i compute the sum of all its children (In LEAF nodes which are the child accounts, this sum is the value in BALANCES itself). Final Result would be:
    TOT -> 10000
      ANA1 -> 3000
        4801001 -> 2000
        4801001 -> 1000
      ANA2 -> 7000
        4802001 -> 3000
        4802002 -> 4000I have tried various ways, and found out a workaround which works for a fixed amount of levels, basically it builds the hierarchy and computes the SYS_CONNECT_BY_PATH, then splits this as a regular expression and uses GROUP BY ROLLUP to compute the higher levels. Then i assemble it again, now with the computed values. Below is the example query:
    select level
        , NVL (vfinal.child_account,'TOTAL') ||' - '||
                            ( SELECT account_desc
                                FROM accounts
                               WHERE account_code = vfinal.child_acct ) account_name
         , to_char(sum_bal, 'fm999g999g999g990') as rolled_up_balance
      from
    select coalesce( princ.lvl3, princ.lvl2, princ.lvl1 ) child_acct
         , DECODE ( princ.lvl2 , NULL
                                     , NULL
                                     , DECODE ( princ.conta_lvl3, NULL
                                     , princ.conta_lvl1,princ.conta_lvl2 ) ) parent_acct
         , sum(princ.balance_amount) sum_bal
    from (
    select hier.lvl1
         , hier.lvl2
         , hier.lvl3
         , hier.parent_account
         , hier.account_code child_acc
         , bal.balance_amount
      from ( select level 
                  , sys_connect_by_path( account_code, '/' ) hierarchy_acct
                  , REGEXP_SUBSTR(sys_connect_by_path( account_code, '/' ),'[^/]+',1,3) lvl3
                  , REGEXP_SUBSTR(sys_connect_by_path( account_code, '/' ),'[^/]+',1,2) lvl2
                  , REGEXP_SUBSTR(sys_connect_by_path( account_code, '/' ),'[^/]+',1,1) lvl1
                  , account_code
                  , parent_account 
               from accounts acc
               where level <= 3
               start with parent_account is null
               connect by nocycle prior account = parent_account
               order siblings by parent_account
               ) hier
          , balances  bal
      where bal.cod_conta  = hier.account_code
    ) princ
    where princ.lvl1 is not null
    group by rollup ( princ.lvl1
                    , princ.lvl2
                    , princ.lvl3 )
    order by princ.conta_lvl1
           , princ.conta_lvl2
           , princ.conta_lvl3
    ) vfinal
    where child_acct is not null
    start with parent_acct is null
    connect by nocycle prior child_acct = parent_acctAll said and done, what i need is to do the same thing for infinite levels, because this query has 3 fixed levels. Do you know how can i structure a new query where, independently of the number of levels, the parent sums are all rolled up like this?
    Thanks a lot in advance! Best Regards!
    Thiago
    Edited by: Thiago on Sep 6, 2011 11:31 AM
    Edited by: Thiago on Sep 6, 2011 1:01 PM

    Hi,
    Thiago wrote:
    Hi all,
    Imagine the following scenario: i have an ACCOUNT table which holds accounts and their hierarchy (currently 5 levels), and a BALANCE table which holds balance records for the accounts. Only CHILD accounts (level 5) have records in the BALANCE table. Simple example:
    CREATE TABLE accounts (account_code VARCHAR2(30), parent_account VARCHAR2(30), account_desc VARCHAR2(400));
    CREATE TABLE balances (account_code VARCHAR2(30), balance_amount NUMBER(18,2));
    INSERT INTO ACCOUNTS ('TOT',NULL,'Total');
    INSERT INTO ACCOUNTS ('ANA1','TOT','General Expenses');
    INSERT INTO ACCOUNTS ('4801001','ANA1','Small Expenses');
    INSERT INTO ACCOUNTS ('4801002','ANA1','Transportation');
    INSERT INTO ACCOUNTS ('ANA2','TOT','Health Expenses');
    INSERT INTO ACCOUNTS ('4802001','ANA2','Healthcare');
    INSERT INTO ACCOUNTS ('4802002','ANA2','Facilities');
    INSERT INTO BALANCES ('4801001', 2000);
    INSERT INTO BALANCES ('4801001', 1000);
    INSERT INTO BALANCES ('4802001', 3000);
    INSERT INTO BALANCES ('4802001', 4000);
    Thanks for posting the CREATE TABLE and INSERT statements. Remember why you do it: so that the people who want to help you can re-create the problem and test their ideas. If the statments don't work, then they are not so useful. None of the INSERT statements you posted work: they all need a VALUES keyword. Please test those statments before you post them.
    Also, make sure that the reuslts you post correspond to the sample data you post. In your sample data, there are no rows in balances for account_codes '4801002' or '4802002'.
    I think you want something like this:
    WITH  connect_by_results      AS
         SELECT     CONNECT_BY_ROOT account_code     AS root_account_code
         ,     account_code
         FROM     accounts
                             -- NOTE: No START WITH clause
         CONNECT BY     parent_account     = PRIOR account_code
    SELECT       c.root_account_code     || ' -> '
                          || TO_CHAR (SUM (b.balance_amount))     AS txt
    FROM           connect_by_results  c
    LEFT OUTER JOIN      balances          b  ON  c.account_code = b.account_code
    GROUP BY  c.root_account_code
    ;

  • Query : Hyperion Performance Scorecard Rollup Functionality

    Hi All,
    Hyperion Performance Scorecard Rollup Functionality in measure and scorecard template.
    Query: We are implementing Hyperion performance scorecard for a client using measure template and scorecard templates after build client came up with following new requirements-
    Strategy hierarchy as follows-
    Level 1- SBU (Parent) Level 2- Groups (Child), 3- Teams( Chilld), 4- Desk ( Child), 5- RM (Child)
    1 Along with Existing scorecards functionality they need to roll up 2 KPIs (Credit Quality1,Credit Quality2) explicitly only at RM level ( at lowest level).
    2- Need to follow this hierarchy for these scorecards roll up (RMs to Desks to Teams to Groups to SBUs)
    3- No of KPIs to be used/modified (credit quality2 means bad assets-non performing loan & Credit quality 1 means good assets-performing loan)
    4- Both these KPIs should roll up to all RMs only but KPI bad asset (Credit Quality2) should not roll up to Desk, to Teams, to Groups, To SBUs but KPI1 Good Assets (performing asset) should roll up to all levels.
    4.1-Example let’s assume there are 2 RMs (RM1 & RM2) RM1 is having bad asset & RM2 is not having bad asset then only for RM1 both KPI should roll up but at above levels 1st KPI (non-performing assets ) should not roll up but second KPI ( performing assets) should roll up.
    5- No of scorecards required means RMs * approx 3000, Desk*Total numbers ,Teams*Total numbers ,Groups*total numbers, finally SBUs*total numbers.
    As per my understanding in the existing HPS design we are using Measure Templates & Scorecard Templates in which all KPIs are automatically rolling up to RMs then from RMs to all above hierarchies, now for this new requirement explicitly we need to create another scorecard (secondary scorecard) with 2 KPIs both should roll up to RMs (3000 approx) but should not roll up to above hierarchy (to Desks to Teams to Groups to SBUs) only we need to roll up 1 KPI to all above hierarchies not the other KPI or this new scorecard.
    As per my understanding in the current design all KPIs are rolling up to all levels.
    Question : In current scenario is there a possibility or solution to restrict a particular KPI to rollup to above levels?*
    Any help would be highly appreciated.

    Thanks for your response!
    I'm not sure that the Power Pivot plugin for Excel will be available here. We use Excel 2010. We have restrictions in our environment. Additionally, we have 32bit Office installed and my understanding is that you need 64 bit on both client and
    server when working with Power Pivot. So exporting Excel Power Pivots from SharePoint 2010 to a 32 bit client wouldn't work (or vice-vera) wouldn't work.
    By robust I mean the ability to utilize different types of data sources (CSV, EXCEL, SQL Server, ORACLE) as well as Data Models, (transactional, analytical, tabular). The ability to handle large datasets, pivot table funcitonality, drill down and drill
    through, rich data visualizations.
    Currently this data is in Oracle. I will need to export it to SQL and I would like to leave it as OLTP since OLAP technologies are not currently in our skill set. Hopefully these can be added in the next year or so.  If Power View loses the bulk
    of it's reporting power when moving to OLTP, I will just build these in SSRS UNLESS, I can use Group By, Rollup and CUBE in my queries to give Power View a data set where  it's capabiliities can be utilized.
    Love them all...regardless. - Buddha

  • Error in Query Result on ADF Table using "ROLLUP"

    Hi, I use Jdeveloper 11.1.2.3.0
    My problem is whenever i run and test my query (on SQL Developer 3.2 release) which has a "Rollup" command, it shows the accurate result with the total and subtotals in the right place as i want it..... But after configuring it on my ADF application via ADF Table, whenever i run it, the subtotals are scattered and misplaced (not being at the position they are meant to be like in SQL Developer)..........
    Please is there a possible way to correct this or is there something im not getting right?
    Please i await any good suggestions or corrections...
    Thank you.
    OBYYS.

    Hi,
    maybe you want to share how from ADF you access your query. Do you use ADF BC, EJB, POJO (with JDBC) to issue the call? If you use ADF BC, how is the value displayed in the tester? Note that SQL Developer just prints the result of a query wheras a table requires you to provide row/column values even for rows that define totals. I assume this to be your problem.
    Frank

  • While Rollup is goingon Can we execute the query

    Hello All
    We have a cube and aggregates built on this cube and daily in my Process chain we have step Rollup.
    Now while Rollup is goingon Can we execute the query which is builut on the same cube? Will the cube will be locked?
    Can we excute query while load is goingon to this cube?
    Regards
    Balji

    Hi Balaji,
    You can execute a query when the roll up is going on. The new data is available to the report only when the rollup is complete, but this will not create locks.
    Hope this helps...

  • Query with GROUP BY ROLLUP

    I have a query :
    SELECT e.deptno,d.dname,e.job,SUM(e.sal)
    FROM emp e,dept d
    WHERE e.deptno = d.deptno
    GROUP BY ROLLUP(e.deptno,d.dname,e.job)
    which gives the output with Deptno and Dept Name repeated for every row, I want them to appear only once for each Dept Num.
    Can you folks help me out on this.
    Thanks and Regards,
    Gaurav Srivastava

    scott@ORA92> BREAK  ON deptno ON dname
    scott@ORA92> SELECT e.deptno, d.dname, e.job, SUM(e.sal)
      2  FROM   emp e, dept d
      3  WHERE  e.deptno = d.deptno
      4  GROUP  BY ROLLUP (e.deptno, d.dname, e.job)
      5  ORDER  BY e.deptno, d.dname, e.job
      6  /
        DEPTNO DNAME          JOB       SUM(E.SAL)
            10 ACCOUNTING     CLERK           1300
                              MANAGER         2450
                              PRESIDENT       5000
                                              8750
                                              8750
            20 RESEARCH       ANALYST         6000
                              CLERK           1900
                              MANAGER         2975
                                             10875
                                             10875
            30 SALES          CLERK            950
                              MANAGER         2850
                              SALESMAN        5600
                                              9400
                                              9400
                                             29025
    16 rows selected.

  • Query related to the group by rollup,cube

    Hello experts,
    I am not getting how the below query gets excuted ,
    {code}
    SELECT department_id,   job_id,   manager_id,   SUM(salary) FROM employess GROUP BY department_id,   ROLLUP(job_id),   CUBE(manager_id)
    {code}
    can anybody simplified this plz ?
    Thanks in advance

    Hi,
    SShubhangi wrote:
    Hello experts,
    I am not getting how the below query gets excuted ,
    {code}
    SELECT department_id,   job_id,   manager_id,   SUM(salary) FROM employess GROUP BY department_id,   ROLLUP(job_id),   CUBE(manager_id)
    {code}
    can anybody simplified this plz ?
    Thanks in advance
    Here's how it works.
    Since the GROUP BY clause includes department_id (not modified by ROLLUP or CUBE), every row of the result set will be limited to a specific department_id.
    Since the GROUP BY clause includes ROLLUP (job_id). some rows of the result set will represent a specific job_id, and some rows will be Super-Aggregate rows, representing all job_ids at the same time.
    Since the GROUP BY clause includes CUBE (manager_id). some rows of the result set will represent a specific manage_id, and some rows will be super-aggregates, representing all manager_ids at the same time.  (When there is only 1 expression inside the parentheses, CUBE means the same thing as ROLLUP).
    Here's how it can be simplified:
    GROUP BY  department_id
    ,         CUBE (job_id, manager_id)
    Here's why:
    Since ROLLUP (x) means the same thing as CUBE (x) - when x is a single expression - then what you posted is equivalent to
    GROUP BY  department_id
    ,         CUBE (job_id)
    ,         CUBE (manager_id)
    and
    GROUP BY  ...
              CUBE (x)
    ,         CUBE (y)
    is just a longer way of saying
    GROUP BY  ...
              CUBE (x, y)
    To understand this better, do some experiments yourself.  Try different combinations of ROLLUP and CUBE, and see what results they produce.
    DO NOT use the hr.employees table for your experiments; it has far too many groups for anyone to understand. Also, department_id and manager_id can be NULL, so it's hard to tell super-aggregate rows from normal aggregate rows.  Even scott.emp is more complicated than necessary.  I suggest you make your own table, like this:
    CREATE TABLE  simp_emp  AS
    SELECT  ename
    ,       deptno
    ,       job
    ,       CASE
                WHEN  job IN ('MANAGER', 'PRESIDENT')
                THEN  'NO'
                ELSE  'YES'
            END                            AS unionized
    ,       EXTRACT (YEAR FROM hiredate)   AS hireyear
    ,       sal
    FROM    scott.emp
    In this table, there are only 2 possible values for unionized, 3 values for deptno, and 4 values for hireyear, and none of those colums are ever NULL.

  • How i use start with and rollup both in one query

    hi master
    sir i use rollup function for subtotal but rollup not give tree
    for tree i want to use start with and connect by function
    but that query give error
    sir how i use both rollup and start with connect by in one query
    for tree wise subtotal
    please give me idea
    thanking you

    hi master
    thank for your reply
    sir i get accid and title from master table and balance from detial table then system give me error
    sir i send me all table and data with query and error
    Sir this is my master table
    SQL> desc chartofacc;
    Name Null? Type
    PARENT NUMBER
    CHILD NUMBER
    ACCID NOT NULL VARCHAR2(15)
    TITLE VARCHAR2(99)
    CAMPID VARCHAR2(2)
    ACTIVE NUMBER
    FSTATUS NUMBER
    Data
    Parent child accid
         1     K1
    1     11     K11
    11     1101     K1101
    11     1102     K1102
    11     1103     K1103
    11     1104     K1104
    11     1105     K1105
    11     1106     K1106
    11     1107     K1107
    11     1108     K1108
    11     1109     K1109
    11     1110     K1110
    11     1111     K1111
    11     1112     K1112
    11     1113     K1113
    11     1114     K1114
    1     12     K12
    12     1201     K1201
    12     1202     K1202
    12     1203     K1203
    1     13     K13
    13     1301     K1301
    1301     130101     K130101
    1301     130102     K130102
    1301     130103     K130103
    1301     130104     K130104
    1301     130105     K130105
    1301     130106     K130106
    1301     130107     K130107
    1301     130108     K130108
    1301     130109     K130109
    1301     130110     K130110
    1301     130111     K130111
    1301     130112     K130112
    1301     130113     K130113
    1301     130114     K130114
    1301     130115     K130115
    13     1302     K1302
    1302     130201     K130201
    1302     130202     K130202
    1302     130203     K130203
    1302     130204     K130204
    1302     130205     K130205
    13     1303     K1303
    1303     130301     K130301
    1303     130302     K130302
    1303     130303     K130303
    13     1304     K1304
    1304     130401     K130401
    1304     130402     K130402
    1304     130403     K130403
    1304     130404     K130404
    1304     130405     K130405
    1304     130406     K130406
    1304     130407     K130407
    1304     130408     K130408
    13     1305     K1305
    1305     130501     K130501
    1305     130502     K130502
    13     1306     K1306
    1306     130601     K130601
    13     1307     K1307
    1307     130701     K130701
    1307     130702     K130702
    1307     130703     K130703
    1307     130704     K130704
    13     1308     K1308
    1308     130801     K130801
    1308     130802     K130802
    1308     130803     K130803
    1308     130804     K130804
    1308     130805     K130805
    1308     130806     K130806
    1308     130807     K130807
    1308     130808     K130808
    1308     130809     K130809
    1308     130810     K130810
    1308     130811     K130811
    1308     130812     K130812
    1308     130813     K130813
    13     1309     K1309
    13     1310     K1310
    13     1311     K1311
    1311     131101     K131101
         2     K2
    2     21     K21
    21     2101     K2101
    2101     210101     K210101
    2101     210102     K210102
    2101     210103     K210103
    2101     210104     K210104
    21     2102     K2102
    2102     210201     K210201
    2102     210202     K210202
    2102     210203     K210203
    2102     210204     K210204
    21     2103     K2103
    2103     210301     K210301
    2103     210302     K210302
    2103     210303     K210303
    2103     210304     K210304
    21     2104     K2104
    2104     210401     K210401
    2104     210402     K210402
    2104     210403     K210403
    2104     210404     K210404
    2     22     K22
    22     2201     K2201
    2201     220101     K220101
    2201     220102     K220102
    2201     220103     K220103
    2201     220104     K220104
    2201     220105     K220105
    22     2202     K2202
    2202     220201     K220201
    2202     220202     K220202
    2202     220203     K220203
    2202     220204     K220204
    22     2203     K2203
    2203     220301     K220301
    2203     220302     K220302
    2203     220303     K220303
    2203     220304     K220304
    22     2204     K2204
    2204     220401     K220401
    2204     220402     K220402
    2204     220403     K220403
    22     2205     K2205
    2205     220501     K220501
    2205     220502     K220502
    220502     22050201     K22050201
    220502     22050202     K22050202
    220502     22050203     K22050203
    220502     22050204     K22050204
    22     2206     K2206
    2206     220601     K220601
    2206     220602     K220602
    2206     220603     K220603
    2206     220604     K220604
    2     23     K23
    23     2301     K2301
    2301     230101     K230101
    2301     230102     K230102
    2301     230103     K230103
    2301     230104     K230104
    2301     230105     K230105
    2301     230106     K230106
    2301     230107     K230107
    2301     230108     K230108
    23     2302     K2302
    2302     230201     K230201
    2302     230202     K230202
    2302     230203     K230203
    2302     230204     K230204
    23     2303     K2303
    2303     230301     K230301
    2303     230302     K230302
    23     2304     K2304
    2304     230401     K230401
    2304     230402     K230402
    2304     230403     K230403
    23     2305     K2305
    2305     230501     K230501
    23     2306     K2306
    2306     230601     K230601
    2306     230602     K230602
    2306     230603     K230603
    2306     230604     K230604
    23     2307     K2307
    23     2308     K2308
    2308     230801     K230801
    2308     230802     K230802
    2308     230803     K230803
    23     2309     K2309
    2309     230901     K230901
    2309     230902     K230902
    2309     230903     K230903
    2309     230904     K230904
    23     2310     K2310
    2310     231001     K231001
    2310     231002     K231002
    2310     231003     K231003
    23     2311     K2311
    2311     231101     K231101
    2311     231102     K231102
    2311     231103     K231103
    23     2312     K2312
    2312     231201     K231201
    2312     231202     K231202
    2312     231203     K231203
    2312     231204     K231204
    23     2313     K2313
    2313     231301     K231301
    2313     231302     K231302
    2313     231303     K231303
    2313     231304     K231304
    2313     231305     K231305
    2313     231306     K231306
    2313     231307     K231307
    2313     231308     K231308
    2313     231309     K231309
    2313     231310     K231310
    2313     231311     K231311
    2313     231312     K231312
    2313     231313     K231313
    2313     231314     K231314
    2313     231315     K231315
    23     2314     K2314
    2314     231401     K231401
    2314     231402     K231402
    2314     231403     K231403
    2314     231404     K231404
    2314     231405     K231405
    2314     231406     K231406
    2314     231407     K231407
    23     2315     K2315
    23     2316     K2316
    2316     231601     K231601
    2316     231602     K231602
    23     2317     K2317
    23     2318     K2318
    23     2319     K2319
    2319     231901     K231901
    2319     231902     K231902
    2319     231903     K231903
    2319     231904     K231904
    2319     231905     K231905
    2319     231906     K231906
    23     2320     K2320
    2320     232001     K232001
         3     K3
    3     31     K31
    31     3101     K3101
    31     3102     K3102
    31     3103     K3103
    31     3104     K3104
    31     3105     K3105
    3     32     K32
    32     3201     K3201
    32     3202     K3202
    32     3203     K3203
    32     3204     K3204
    32     3205     K3205
    32     3206     K3206
    32     3207     K3207
         4     K4
    4     41     K41
    41     4101     K4101
    4101     410101     K410101
    4101     410102     K410102
    4101     410103     K410103
    4101     410104     K410104
    4101     410105     K410105
    4101     410106     K410106
    4101     410107     K410107
    4101     410108     K410108
    4101     410109     K410109
    4101     410110     K410110
    4101     410111     K410111
    4101     410112     K410112
    4101     410113     K410113
    4101     410114     K410114
    4101     410115     K410115
    4101     410116     K410116
    4101     410117     K410117
    4101     410118     K410118
    4101     410119     K410119
    4101     410120     K410120
    4101     410121     K410121
    4101     410122     K410122
    4101     410123     K410123
    4101     410124     K410124
    4101     410125     K410125
    4101     410126     K410126
    4101     410127     K410127
    4101     410128     K410128
    4101     410129     K410129
    4101     410130     K410130
    4101     410131     K410131
    4101     410132     K410132
    41     4102     K4102
    41     4103     K4103
    41     4104     K4104
    4104     410401     K410401
    4104     410402     K410402
    4104     410403     K410403
    4104     410404     K410404
    41     4105     K4105
    41     4106     K4106
    41     4107     K4107
    41     4108     K4108
    4108     410801     K410801
    4108     410802     K410802
    4108     410803     K410803
    41     4109     K4109
    4109     410901     K410901
    4109     410902     K410902
    4109     410903     K410903
    41     4110     K4110
    41     4111     K4111
    4111     411101     K411101
    4111     411102     K411102
    4111     411103     K411103
    41     4112     K4112
    4112     411201     K411201
    41     4113     K4113
    4113     411301     K411301
    41     4114     K4114
    4114     411401     K411401
    4114     411402     K411402
         5     K5
    5     51     K51
    51     5101     K5101
    51     5102     K5102
    51     5103     K5103
    51     5104     K5104
    51     5105     K5105
    51     5106     K5106
    51     5107     K5107
    51     5108     K5108
    51     5109     K5109
    51     5110     K5110
    51     5111     K5111
    51     5112     K5112
    51     5113     K5113
    51     5114     K5114
         6     K6
    6     61     K61
         7     K7
    7     71     K71
    7     72     K72
    7     73     K73
    7     74     K74
    7     75     K75
    7     76     K76
    This is my detil table
    SQL> desc accbal;
    Name Null? Type
    ACCID VARCHAR2(15)
    YEARID NUMBER
    CRBAL NUMBER
    DRBAL NUMBER
    ENTDATE DATE
    BALID NUMBER
    Data in detail
    K1101     46291132     
    K1102     13182173     
    K1103     23784045     
    K1107     10001795     
    K1108     9083529     
    K1110     4224350     
    K1112     6696832     
    K1113     7963381     
    K1114     742766     
    K1201     1486082     
    K130104     1977616     
    K130106     736266     
    K130107     396673     
    K130108     42751     
    K130109     298362     
    K130110     187696     
    K130111     537     
    K130112     942     
    K130113     987     
    K130114     1272     
    K130115     40000     
    K130205     259941     
    K130303     177716     
    K130406     809719     
    K130408     1786091     
    K130701     301000     
    K130702     151200     
    K130703     7570     
    K130704     34400     
    K1308          
    K130801     5400     
    K130802     45000     
    K130803     10856     
    K130807     24300     
    K130808     16500     
    K130810     104500     
    K130811     60000     
    K130812     181000     
    K130813     1750000     
    K1309     1225565     
    K1310     2176259     
    K1311          
    K131101     788780     
    K410101          24926
    K410102          9545
    K410103          28500
    K410104          8192
    K410105          847
    K410106          37100
    K410107          2332
    K410108          9844
    K410109          7843
    K410110          9313
    K410111          1425
    K410112          6089
    K410113          15497
    K410114          5790
    K410115          4251
    K410116          22293
    K410117          855
    K410118          6497
    K410119          14996
    K410120          124214
    K410121          6713
    K410122          1567
    K410123          75821
    K410124          5085
    K410125          7125
    K410126          4342
    K410127          21485
    K410128          641111
    K410129          589
    K410130          50
    K410131          163900
    K410132          3849
    K4105          3946489
    K4107          100000
    K410801          972011
    K410802          1707806
    K410803          116450
    K4110          13113874
    K411101          98335
    K411102          32454
    K411103          53569
    K411201          25327406
    K411301          7143103
    K411401          4500000
    K411402          12754
    K5102          2120031
    K5103          13543810
    K5107          4596103
    K5108          5604493
    K5110          2008401
    K5112          2182778
    K5113          4748537
    K5114          556914
    K61          43297680
    Sir I use this query
    select lpad(' ',2*(level-1)) || to_char(child),title,sum(drbal),sum(crbal),
    from chartofacc, accbal
    where chartofacc.accid=accbal.accid(+)
    start with parent is null
    connect by prior child = parent
    group by rollup(substr(mas.accid,2,1),substr(mas.accid,3,1),substr(mas.accid,4,2),substr(mas.accid,6,2) ,chartofacc.accid,title,fstatus);
    sir this query not give me result and give me error this
    SQL> /
    from chartofacc, accbal
    ERROR at line 2:
    ORA-00936: missing expression
    Please give me idea how I get tree type subtotal tribalance
    Thanking you
    Aamir

Maybe you are looking for

  • How to create a procedure using program unit

    Hai All Ii have created a procedure like this PROCEDURE Duty_calc IS procedure w_Time is begin update dail_att set wtime= (select lpad((to_number(to_char(outtime,'hh24mi')-to_char(intime,'hh24mi'))),4,0) from dail_att where attend_date=f_date); end w

  • Number of rows in all tables

    Hi, I need to query in max db to find number of rows exist in each and every table. Is there any query we can use to find in a single shot? Example: S.NO Table Name      Number of rows 1          A                    3000 2          B                

  • NO PUEDO convertir CR2 de canon t5

    NO PUEDO convertir ARCHIVOS RAW DE CANON T5 CON DNG CONVERTER 8 Hola ! uso Photoshop CS5, tengo instalado DNG converter 8 y cuando deseo convertir los archivos CR2 de una canon t5 aparece un mensaje que dice : La carpeta de origen no contiene ningún

  • Trouble with music fade out

    I just finished a photo slide show in iMovie and have used iTunes music from a CD. The problem is that my slide show is shorter than the music and I want to do a "fade out" with the music. I've done this before with music within the iMovie program wh

  • Export as GIF file in CS5

    Hi,   Can some one give me documentation of how to export as GIF file. We are using CS5 server? Is ExportFormat.GIF valid format? Thanks Vish