To calculate the variance percentage

In below given query , i want to calculate the variance between Forecast and sale.
Here
FRCST - Forecast
SALE - Sale
FRCST-sale - Difference between forecast and sale
Now i want to display one more column i.e Variance
I need a statement to caluclate the DIFF / FRCST. The result should be displayed according the conditions :
1) If Forecast is Zero, and Sale is Zero - then result should be No Forecast and Sale for the item
2) If Forecast is Zero, and sale is not Zero, then Sale against Nil Forecast
3) If Sale is Zero and Forecast is not Zero then No sale against Forecast
4) If difference between Forecast and Sale is zero (Both are non zero numbers) then No Variance
5) If Forecat and Sale difference is not Zero then DIFF / FRCST
The problem arise when the FRCST is Zero and Sale is non zero then divide by zero occurs
Kindly guide me on this..
SELECT ITEM_NAME, NVL(FRCST,0) FRCST, NVL(SALE,0) SALE, NVL((FRCST-SALE),0) DIFF
FROM
SELECT DISTINCT ITEM_NAME
FROM OM_ITEM
WHERE ITEM_CODE LIKE 'F%'
AND ITEM_FRZ_FLAG_NUM<>1
SELECT FYEAR, FMNTH, FITEM_NAME,FRCST
FROM FORECAST
WHERE FYEAR||'-'||FMNTH = :YM
SELECT SYEAR, SMNTH, SITEM_NAME, SALE
FROM SALE
WHERE SYEAR||'-'||SMNTH = :YM
WHERE ITEM_NAME = FITEM_NAME(+)
AND ITEM_NAME = SITEM_NAME(+)
ORDER BY 1

I had changed the query as given below . Its giving me result, but how could i convert the case statement into decode. Is there any simple way for this:
SELECT
ITEM_NAME, FRCST, SALE, DIFF,
(CASE
WHEN FRCST = 0 AND SALE = 0 THEN 'No transaction '
WHEN FRCST = 0 AND SALE <>0 THEN 'Sale against Nil Forecast'
WHEN FRCST<> 0 AND SALE = 0 THEN 'No Sale against Forecast'
WHEN FRCST<>0 AND SALE<>0 AND DIFF=0 THEN 'No Variance'
ELSE TO_CHAR(ROUND((DIFF/FRCST),2))||'%'
END)VARIANCE
FROM
SELECT ITEM_NAME, NVL(FRCST,0) FRCST, NVL(SALE,0) SALE, NVL((FRCST-SALE),0) DIFF
FROM
( SELECT DISTINCT ITEM_NAME FROM OM_ITEM
WHERE ITEM_CODE LIKE 'F%'
AND ITEM_FRZ_FLAG_NUM<>1
( SELECT FYEAR, FMNTH, FITEM_NAME, FRCST
FROM FORECAST
WHERE FYEAR||'-'||FMNTH = :YM
( SELECT SYEAR, SMNTH, SITEM_NAME, SALE FROM SALE
WHERE SYEAR||'-'||SMNTH = :YM
WHERE ITEM_NAME = FITEM_NAME(+) AND ITEM_NAME = SITEM_NAME(+)
ORDER BY 1
)

Similar Messages

  • How to calculate the variance in PO price history?

    hi
    i hav standard report ME1P, since i need to do some modifications in this program i copied to Y prgrm,,,'
    im getting all the values properly...
    but my prblm is im not getting how to calculate the variance? im not getting the logic behid it...
    can anybody expln me in breif plz....
    Regards
    Smitha

    Hi Venu,
    there is another way as well, however, you won't be able to see Variance and Variance% as a saperate keyfigure which is not under the period. Thats the reason I didn't mention it earlier.
    What you can do is, Drag the period to the columns, Now create a structure that has the two keyfigures std price, moving price. Here if you add Variance and Variance%, Then these CKF's would come under period as well, which you don't need. And the system won't allow you to add these CKF's outside this structure. The reason being because the interpretation of the data then wouldn't make any sense here. You can create a new structure as well with these CKF's but they would become a subpart of your previous structure.
    choose the required characteristics in the Rows section. Save it.
    Let us know, Sorry man, can't help u much at this problem.
    regards,
    Sree.

  • How to calculate the variance

    good day.. i am an end-user using oracle desktop discoverer 4, how will i calculate the variance in a crosstab as follows:
    ......... total cost total cost ........
    project draft Original variance
    project1 1000 400 500
    project2 5000 1000 4000
    thanks and regards

    Hi Venu,
    there is another way as well, however, you won't be able to see Variance and Variance% as a saperate keyfigure which is not under the period. Thats the reason I didn't mention it earlier.
    What you can do is, Drag the period to the columns, Now create a structure that has the two keyfigures std price, moving price. Here if you add Variance and Variance%, Then these CKF's would come under period as well, which you don't need. And the system won't allow you to add these CKF's outside this structure. The reason being because the interpretation of the data then wouldn't make any sense here. You can create a new structure as well with these CKF's but they would become a subpart of your previous structure.
    choose the required characteristics in the Rows section. Save it.
    Let us know, Sorry man, can't help u much at this problem.
    regards,
    Sree.

  • Calculate the variance between quarters and store it in a scenario

    Hi,
    Can anyone suggets how I can write a rule to calculate the variances between quarters, Qtr1 vs Qtr2, Qtr2 vs Qtr3 etc, and store them in a scenario so that I dont calculatethem on a report ?
    Thanks,
    IK

    Hi. Why don't you want to do this on the report - it's much easier and you can get favorable/unfavorable comparisons? But, if you want to do the rule, here's the approach.
    Create the scenario with QTD as the frequency so you don't have monthly periods
    Limit the rule to run just for the scenario and don't run any other rules for the scenario
    Use a select case to determine which period (Q1, etc.) is being calc'd to populate variables that contain the source period and year (for going back a year to Q4).
    Write the rule to compare data from current quarter in the real scenario to the prior quarter in the real scenario. Something like HS.Exp "A#ALL = A#ALL.S#Actual.P#Jun.W#QTD - A#ALL.S#Actual.P#Mar.W#QTD. But, you may want to adjust this to calculate a favorable/unfavorable variance on the revenue/expense accounts, so you'd need to loop through the accounts and look at the account type.
    You'd want to rerun the rule at all value members for both base entities and parent entities. May need to clear all existing data (HS.Clear "A#ALL") in the scenario/year/period/entity/value first.
    Do a consolidate all on the scenario to pull the data across and do the math
    Have fun, but you really should still with doing the comparison in the reports.
    Eric

  • KKS2 can't calculate the variance in the production order

    We have some simi-finished product orders.  All these simi-finished products  were produced in previous period and got receipted into the warehouse. However, for some reason we don't know, there are still some cost balance remain in the orders themselves, although they had been settled in previous period. 
    So far I only found these simi-finished products were not maintained with Variance Keys.
    So I maintained the variance keys for the orders. however, it doesn't work, when I run KKS2 to calculate the variance in the order, the order's Target Costs, Actual Cost and Allocated Actl Costs are all zero. So the variance are zero. In fact, that order's variance are -123.8, for example. Since the variance calculated by KKS2 is zero, there is no reference for KO88 to settle this order. The variance -123.8 will always remain in the order.
    I can't close these orders for the cost balances are not zero.
    Anyone could give me some suggestions to settle the variance?
    Thanks,
    Jim
    best regards.

    Hi
    Because the var keys were not existing on the order, it did not calculate the variance... However, once you maintain them in the order, KKS2 should prove successful... Did you calculate the variance in the correct period after maintaining the variance keys?
    How many such orders are there and whats the balance on these orders?
    Note that, to settle variance to FI, it is not necessary to calculate variance in KKS1/2... KKS1/2 only helps you to settle variance to COPA.... Your FI will still be updated with variance, even if you do not caluclate KKS1/2
    So, if the no of cases and the amount involved is not much, you can think of executing KO88 for them and then manually update values in COPA for these orders for record type C... However, keep this as a last option.... Ideally, once you maintain variance keys, variance should get calculated
    Regards
    Ajay M

  • Calculate the variance between two row

    Post Author: jane
    CA Forum: WebIntelligence Reporting
    Hi,
    I'm new to BO and wondering whether there is a way to calculate the variance between two rows. I'm working on a report which requires to display the change of two day's data. For instance, I have a table in a format as
    Date
    Sales Amount
    3/12/2008
    2300.00
    2/12/2008
    1280.00
    Changed
    1020.00
    I'd like to display the "Changed" column. Is there a way to do that in BO InfoView? In Excel, you can use the formular by identify the two cells.
    Thanks!

    Post Author: Vinl
    CA Forum: WebIntelligence Reporting
    I am having the same problem and am steping outside of the box and cannot progress.
    Seems to me that you are kind of saying that the only way to get around this is to create an individual object in Designer? I cannot find a way of cementing values as a variable in order for a variance to be created.
    I am trying to do it at column level mind you, which should not make that much difference....
    Simple SQL database. I have created an object called "Year" which takes a date and converts it to a year. I then have another object created "Total sales", put the 2 in a table get the right results...try and create a year on year variance from that...no chance...
    Used to work ok...?

  • How to  calculate the monthly percentage of the goods delivered

    hi all,
    In my requirement i have to count the number of goods delivered to the customer per year and i have the calculate the percentage of goods delivered monthly.please help me .

    Hello Duygu,
    restrict the original cost keyfigure with a variable which is based on fiscal period (this will be actual cost). And then create a new keyfigure(copy of original keyfigure) and use same variable but in detail of restriction use -1 for offset( this will be previous). And then define a new formula and subtract actual from previous or opposite)
    Sarhan.

  • How can I calculate the interest percentage dynamically?

    Hi All,
    Please look at these tables (Customer and Rates), having some sample data. I've created a function for returning the interest percentage for a particular customer based upon his/her investment start date and end date. I'm getting the desired result but I'm wondering if I need calculate the composite interest here...then how can I do that? Suppose a customer has invested some amount for 45 days, then I need to calculate the interest for initial 30 days as 5% and additional 15 days as 6% and I need to give the final amount. In this case how can I pull this task off? Please give me some ideas and correct me if I'm wrong. I just want to know how can we do this interest calculation by an Oracle program?
    Regards
    BS2012
    Customer Table
    CUSTOMER_ID     AMOUNT     START_DATE     END_DATE
    1000             40000     15-JAN-13     15-FEB-13
    1001             34000     15-DEC-12     15-FEB-13
    1002             35678     15-NOV-12     15-FEB-13
    Rates Table
    RATE_PCT     LOW_TENURE     HIGH_TENURE
    5                    0     30
    6                    0     60
    7                    0     90
    CREATE OR REPLACE FUNCTION
    F_INTEREST_PCT (V_CUSTOMER_ID IN CUSTOMER.CUSTOMER_ID%TYPE)
      RETURN NUMBER AS V_RATE_PCT NUMBER;
      BEGIN
        SELECT A.RATE_PCT INTO V_RATE_PCT
        FROM RATES A, CUSTOMER B WHERE (B.END_DATE - B.START_DATE) BETWEEN A.LOW_TENURE AND A.HIGH_TENURE
                                   AND B.CUSTOMER_ID = V_CUSTOMER_ID;
        RETURN V_RATE_PCT;
      EXCEPTION
        WHEN NO_DATA_FOUND THEN
        ROLLBACK;
        DBMS_OUTPUT.PUT_LINE(SQLERRM);
        WHEN OTHERS THEN
        ROLLBACK;
        DBMS_OUTPUT.PUT_LINE(SQLERRM); 
      END F_INTEREST_PCT;

    BS2012 wrote:
    Hi All,
    Please look at these tables (Customer and Rates), having some sample data. I've created a function for returning the interest percentage for a particular customer based upon his/her investment start date and end date. I'm getting the desired result but I'm wondering if I need calculate the composite interest here...then how can I do that? Suppose a customer has invested some amount for 45 days, then I need to calculate the interest for initial 30 days as 5% and additional 15 days as 6% and I need to give the final amount. In this case how can I pull this task off? Please give me some ideas and correct me if I'm wrong. I just want to know how can we do this interest calculation by an Oracle program?
    Regards
    BS2012
    Customer Table
    CUSTOMER_ID     AMOUNT     START_DATE     END_DATE
    1000             40000     15-JAN-13     15-FEB-13
    1001             34000     15-DEC-12     15-FEB-13
    1002             35678     15-NOV-12     15-FEB-13
    Rates Table
    RATE_PCT     LOW_TENURE     HIGH_TENURE
    5                    0     30
    6                    0     60
    7                    0     90
    CREATE OR REPLACE FUNCTION
    F_INTEREST_PCT (V_CUSTOMER_ID IN CUSTOMER.CUSTOMER_ID%TYPE)
    RETURN NUMBER AS V_RATE_PCT NUMBER;
    BEGIN
    SELECT A.RATE_PCT INTO V_RATE_PCT
    FROM RATES A, CUSTOMER B WHERE (B.END_DATE - B.START_DATE) BETWEEN A.LOW_TENURE AND A.HIGH_TENURE
    AND B.CUSTOMER_ID = V_CUSTOMER_ID;
    RETURN V_RATE_PCT;
    EXCEPTION
    WHEN NO_DATA_FOUND THEN
    ROLLBACK;
    DBMS_OUTPUT.PUT_LINE(SQLERRM);
    WHEN OTHERS THEN
    ROLLBACK;
    DBMS_OUTPUT.PUT_LINE(SQLERRM); 
    END F_INTEREST_PCT;
    You will need to work out a formula or process to get the results you want, then write the code to do what you devise. When I have to do something hard it helps to write out what I want to do in psuedocode that I alter translate to real code. Let's say I want to do a factorial (1 * 2 * 3 * 4 ...) could be something like
    get limit value
    set factorial to 1
    foreach loop value from 1 to limit
      multiply factorial by loop index
      v_factorial_n := 1; --set factorial to 1
      for i in 1..p_limit_n loop --p_limit_n defined elsewhere
        v_factorial_n := v_factorial_n * i;
      end loop; --loop to compute factorial
    . . .

  • How to calculate the correct percentage

    Hi Experts,
    Here is the problem i am facing.
    Column 1--Column 2--Column 3--
    Column 4
    Row1---Value A--Value BA x B--
    AxB/((AxB)+(CxD))%
    Row2---Value C--Value DC x D--
    CxD/((AxB)+(CxD))%
    Row1+Row2---A + CB + D--FormulaCollision--
    100%
    In this example, there are two rows and two columns with simple values, the third row is a simple summation formula and the third column is a simple multiplication and fourth column is simple % calculation. In the cell in which the row and column formulas meet, it is not clear which calculation should be made.
    If you calculate according to the column formula in this cell, the cell contains (AC)x(BD). If you calculate according to the rows formula in this cell, the cell contains (AxB)+(CxD). The result gives a different value.
    Experts,
    Currently my result is (AC)x(BD). I need to display (AxB)+(CxD).
    I am able to acheive (AxB)+(CxD) by Calculating result as 'Summation'.
    But,
    Is there a way I can acheive (AxB)+(CxD) without doing 'Summation' as that would help me in correctly calculating percentages in column 4 as
    AxB/((AxB)+(CxD))% and
    CxD/((AxB)+(CxD))%
    instead of
    AxB/((AC)x(BD))% and
    CxD/((AC)x(BD))%
    BTW, i tried this link:http://help.sap.com/saphelp_nw04/helpdata/en/d2/02223c5f00612be10000000a11402f/frameset.htm
    Still not helpful

    Nope.
    In a row and columns you need to create structures, by right clicking on the top the rows and columns, you will see create structure, you define it as you want one Key figure and/or one or more characteristics. That is the structure, as soon as you create that structure you will see a cell definition in the menu enabled.
    You use this definition to calculate as I described earlier.
    Let me know.
    thanks.
    Wond

  • How can i calculate the attendance percentage.

    Dear Guru's,
    Any standard function module is there for calculating attendance percentage.
    please give solution.

    Dear Guru's,
    Any standard function module is there for calculating attendance percentage.
    please give solution.

  • How to calculate the monthly variances in the query

    Hi Gurus;
    I need to design a query which calculates the variance of costs with respect to the previous month. I want to select a fiscal period range and only show the variances for these selected periods. However when I enter a range the calculations for the first period dont work. Also If I add the fiscal period characteristic over the structure the formulas are not calculated for the previous period.
    Need help?
    How can I calculate the variance of costs with respect to previous months and display them monthly?
    Thanx a lot in advance,
    Duygu Sile

    Hello Duygu,
    restrict the original cost keyfigure with a variable which is based on fiscal period (this will be actual cost). And then create a new keyfigure(copy of original keyfigure) and use same variable but in detail of restriction use -1 for offset( this will be previous). And then define a new formula and subtract actual from previous or opposite)
    Sarhan.

  • Calculate Revenue's Percentage per Year, Month or any filter that is applied to the Dashboard in DAX using Excel PowerView.

    Hello folks,
    I am facing an odd issue here with a Dashboard Report in PowerView.
    The task is to display, in a table, a percentage of total (revenue) by any filter that the client wants. For instance, if the client selects the year (to be short) 2013, it should display for each Customer the percentage of total as Participation field.
    If the client select 2014, the data should change dinamically and the same if he selects both years.
    The issue that I am facing is that it calculates correctly (showing total of 100%) for either 2013 or 2014, but when I select both it sums up and shows 200% total, altering all other lines with the same behavior.
    So, basically what I need is to immitate a PARTITION BY analytic function, for instance, PARTITION BY YEAR and calculate the data over the total of the selected year only (if there are many years selected, the should be calculated over it, resulting in a
    100% total).
    Here is the formula that I am using in the column:
    =[Valor NF]/CALCULATE(SUM([Valor NF]);ALLEXCEPT(Faturamento;Faturamento[Ano]))
    Where [Valor NF] is the source column (invoyce total), Faturamento is my table (Revenue) and [Ano] is the year column, (I am calculating only by year to test)
    I'd appreciate any suggestion.
    Thanks in advance
    MCP

    Hi Nick,
      Thanks for your suggestion and it  worked for me   I  added the 'System message' web item and set the visibility to 'Hidden'  .Now I am not getting any message. Thank you for both.
    Thanks & Regards,
    Raja

  • How to calculate the percentage of free space for a table in Oracle

    okay, I am a little confused here. I have been searching the web and looking at a lot of documents. What I basically want to find out is this, how do I calculate the difference between the number of bytes a table is using and the total bytes allocated to a table space (going that way to get percent free for a particular table). So I need a byte count of a table and total table space and the percentage difference. I have been looking at the DBA_TABLES DBA_TABLESPACES and DBA_SEGMENTS views. I have tried to calculated the space as num_rows * avg_row_len (if I am wrong, let me know). I have been trying to compare that calculation to the number in DBA_TABLESPACES and DBA_SEGMENTS. I am just looking for the total space allocated to the table space that the table sits in (seem logical right now) to make the percentage value work. Thus I want to be able to track the table as it grows as compated to the table space it sits in to see a value as it changes over time (days, weeks, etc.) each time I run this script I am working on.
    Can someone get me straight and help me to find out if I am looking in the right places. Any advice would help.
    Edward

    You can use a little modified version of dbms_space from Tom, show_space. Have a look,
    SQL> create table test222 as select * from all_objects;
    Table created.
    SQL> delete from test22 where rownum<=100;
    delete from test22 where rownum<=100
    ERROR at line 1:
    ORA-00942: table or view does not exist
    SQL> delete from test222 where rownum<=100;
    100 rows deleted.
    SQL> analyze table test222 compute statistics;
    Table analyzed.
    SQL>  create or replace procedure show_space
      2  ( p_segname in varchar2,
      3    p_owner   in varchar2 default user,
      4    p_type    in varchar2 default 'TABLE',
      5    p_partition in varchar2 default NULL )
      6  -- this procedure uses authid current user so it can query DBA_*
      7  -- views using privileges from a ROLE and so it can be installed
      8  -- once per database, instead of once per user that wanted to use it
      9  authid current_user
    10  as
    11      l_free_blks                 number;
    12      l_total_blocks              number;
    13      l_total_bytes               number;
    14      l_unused_blocks             number;
    15      l_unused_bytes              number;
    16      l_LastUsedExtFileId         number;
    17      l_LastUsedExtBlockId        number;
    18      l_LAST_USED_BLOCK           number;
    19      l_segment_space_mgmt        varchar2(255);
    20      l_unformatted_blocks number;
    21      l_unformatted_bytes number;
    22      l_fs1_blocks number; l_fs1_bytes number;
    23      l_fs2_blocks number; l_fs2_bytes number;
    24      l_fs3_blocks number; l_fs3_bytes number;
    25      l_fs4_blocks number; l_fs4_bytes number;
    26      l_full_blocks number; l_full_bytes number;
    27
    28      -- inline procedure to print out numbers nicely formatted
    29      -- with a simple label
    30      procedure p( p_label in varchar2, p_num in number )
    31      is
    32      begin
    33          dbms_output.put_line( rpad(p_label,40,'.') ||
    34                                to_char(p_num,'999,999,999,999') );
    35      end;
    36  begin
    37     -- this query is executed dynamically in order to allow this procedure
    38     -- to be created by a user who has access to DBA_SEGMENTS/TABLESPACES
    39     -- via a role as is customary.
    40     -- NOTE: at runtime, the invoker MUST have access to these two
    41     -- views!
    42     -- this query determines if the object is a ASSM object or not
    43     begin
    44        execute immediate
    45            'select ts.segment_space_management
    46               from dba_segments seg, dba_tablespaces ts
    47              where seg.segment_name      = :p_segname
    48                and (:p_partition is null or
    49                    seg.partition_name = :p_partition)
    50                and seg.owner = :p_owner
    51                and seg.tablespace_name = ts.tablespace_name'
    52               into l_segment_space_mgmt
    53              using p_segname, p_partition, p_partition, p_owner;
    54     exception
    55         when too_many_rows then
    56            dbms_output.put_line
    57            ( 'This must be a partitioned table, use p_partition => ');
    58            return;
    59     end;
    60
    61
    62     -- if the object is in an ASSM tablespace, we must use this API
    63     -- call to get space information, else we use the FREE_BLOCKS
    64     -- API for the user managed segments
    65     if l_segment_space_mgmt = 'AUTO'
    66     then
    67       dbms_space.space_usage
    68       ( p_owner, p_segname, p_type, l_unformatted_blocks,
    69         l_unformatted_bytes, l_fs1_blocks, l_fs1_bytes,
    70         l_fs2_blocks, l_fs2_bytes, l_fs3_blocks, l_fs3_bytes,
    71         l_fs4_blocks, l_fs4_bytes, l_full_blocks, l_full_bytes, p_partition);
    72
    73       p( 'Unformatted Blocks ', l_unformatted_blocks );
    74       p( 'FS1 Blocks (0-25)  ', l_fs1_blocks );
    75       p( 'FS2 Blocks (25-50) ', l_fs2_blocks );
    76       p( 'FS3 Blocks (50-75) ', l_fs3_blocks );
    77       p( 'FS4 Blocks (75-100)', l_fs4_blocks );
    78       p( 'Full Blocks        ', l_full_blocks );
    79    else
    80       dbms_space.free_blocks(
    81         segment_owner     => p_owner,
    82         segment_name      => p_segname,
    83         segment_type      => p_type,
    84         freelist_group_id => 0,
    85         free_blks         => l_free_blks);
    86
    87       p( 'Free Blocks', l_free_blks );
    88    end if;
    89
    90    -- and then the unused space API call to get the rest of the
    91    -- information
    92    dbms_space.unused_space
    93    ( segment_owner     => p_owner,
    94      segment_name      => p_segname,
    95      segment_type      => p_type,
    96      partition_name    => p_partition,
    97      total_blocks      => l_total_blocks,
    98      total_bytes       => l_total_bytes,
    99      unused_blocks     => l_unused_blocks,
    100      unused_bytes      => l_unused_bytes,
    101      LAST_USED_EXTENT_FILE_ID => l_LastUsedExtFileId,
    102      LAST_USED_EXTENT_BLOCK_ID => l_LastUsedExtBlockId,
    103      LAST_USED_BLOCK => l_LAST_USED_BLOCK );
    104
    105      p( 'Total Blocks', l_total_blocks );
    106      p( 'Total Bytes', l_total_bytes );
    107      p( 'Total MBytes', trunc(l_total_bytes/1024/1024) );
    108      p( 'Unused Blocks', l_unused_blocks );
    109      p( 'Unused Bytes', l_unused_bytes );
    110      p( 'Last Used Ext FileId', l_LastUsedExtFileId );
    111      p( 'Last Used Ext BlockId', l_LastUsedExtBlockId );
    112      p( 'Last Used Block', l_LAST_USED_BLOCK );
    113  end;
    114
    115  /
    Procedure created.
    SQL> desc show_space
    PROCEDURE show_space
    Argument Name                  Type                    In/Out Default?
    P_SEGNAME                      VARCHAR2                IN
    P_OWNER                        VARCHAR2                IN     DEFAULT
    P_TYPE                         VARCHAR2                IN     DEFAULT
    P_PARTITION                    VARCHAR2                IN     DEFAULT
    SQL> set serveroutput on
    SQL> exec show_space('TEST222','SCOTT');
    BEGIN show_space('TEST222','SCOTT'); END;
    ERROR at line 1:
    ORA-00942: table or view does not exist
    ORA-06512: at "SCOTT.SHOW_SPACE", line 44
    ORA-06512: at line 1
    SQL> conn / as sysdba
    Connected.
    SQL> grant sysdba to scott;
    Grant succeeded.
    SQL> conn scott/tiger as sysdba
    Connected.
    SQL> exec show_space('TEST222','SCOTT');
    BEGIN show_space('TEST222','SCOTT'); END;
    ERROR at line 1:
    ORA-06550: line 1, column 7:
    PLS-00201: identifier 'SHOW_SPACE' must be declared
    ORA-06550: line 1, column 7:
    PL/SQL: Statement ignored
    SQL> exec scott.show_space('TEST222','SCOTT');
    PL/SQL procedure successfully completed.
    SQL> set serveroutput on
    SQL> exec scott.show_space('TEST222','SCOTT');
    Unformatted Blocks .....................               0
    FS1 Blocks (0-25)  .....................               0
    FS2 Blocks (25-50) .....................               1
    FS3 Blocks (50-75) .....................               0
    FS4 Blocks (75-100).....................               1
    Full Blocks        .....................             807
    Total Blocks............................             896
    Total Bytes.............................       7,340,032
    Total MBytes............................               7
    Unused Blocks...........................              65
    Unused Bytes............................         532,480
    Last Used Ext FileId....................               4
    Last Used Ext BlockId...................           1,289
    Last Used Block.........................              63
    PL/SQL procedure successfully completed.
    SQL>http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:5350053031470
    I use this to find the space allocations.
    Just read your post again,this is not going to show you the percentage of the free/used space. This is going to be the number of blocks which are free/used. For the growth trend, you can look at (in 10g) Oracle EM. It has added now,Segment Growth Trend report which can show you for each object,comparing to the allocated space to the object,how much space is being used by it.
    HTH
    Aman....

  • How do calculate the average of a group of percentages excluding percentages listed as zero on Numbers?

    Hey all
    This is driving me crazy!
    I need to calculate the average of a group of percentages excluding cells listed as '0%'.
    Please see screen print below, numbers highlighted need to be averaged, when the table is filled out correctly some will remain '0%' whilst others will have a value, I want the average to be calculated only using numbers with a value greater than '0'.
    FYI I am looking for the result to display in 'X2'
    Thanks :-)

    you can use the averageif() function. Here is a simple example to get you started:
    In this example the average if() function averages values that are non-zero
    C2=AVERAGEIF(A1:E1,"<>0",A1:E1)
    this is shorthand for select cell C2, then type (or copy and paste from here) the formula:
    =AVERAGEIF(A1:E1,"<>0",A1:E1)

  • How to calculate the in use percentage of cache ?

    Hi, All,
    I have two questions here:
    1. Can we calculate the proper cache size based on the average key/data pair size and the number of key/data pairs? Is there any formula or something? ( I doubt it :), so next is the second question )
    2. If we set a fixed cache size, and ensure that it has almost 100% hit rate for all the entries accesses. Does this mean that the cache is enough? And if yes, can we calculate how much percentage of the cache is actually in use?
    Thanks in advance.

    Hi,
    user647934 wrote:
    1. Can we calculate the proper cache size based on the average key/data pair size and the number of key/data pairs? Is there any formula or something? ( I doubt it :), so next is the second question ) You can estimate that, just that you should also consider: the page size and how many records will fit on a page.
    Depending on your type of access method, you can check here for formulas that are estimating the total database size (you can find them here: http://www.oracle.com/technology/documentation/berkeley-db/db/ref/am_misc/diskspace.html ), and just translate that to the cache size. Be aware that any cache size less than 500MB is automatically increased by 25% to account for buffer pool overhead.
    user647934 wrote:
    2. If we set a fixed cache size, and ensure that it has almost 100% hit rate for all the entries accesses. Does this mean that the cache is enough? And if yes, can we calculate how much percentage of the cache is actually in use?I think that you can find everything you need by calling "db_stat -m" or DB_ENV->memp_stat for detailed cache statistics.
    db_stat: http://www.oracle.com/technology/documentation/berkeley-db/db/utility/db_stat.html
    DB_ENV->memp_stat: http://www.oracle.com/technology/documentation/berkeley-db/db/api_c/memp_stat.html
    The fields returned by this are:
    size_t st_gbytes;
    * Gigabytes of cache (total cache size is st_gbytes + st_bytes).
    size_t st_bytes;
    * Bytes of cache (total cache size is st_gbytes + st_bytes).
    u_int32_t st_ncache;
    * Number of caches.
    u_int32_t st_max_ncache;
    * Maximum number of caches, as configured with the DB_ENV->set_cache_max method.
    roff_t st_regsize;
    * Individual cache size, in bytes.
    size_t st_mmapsize;
    * Maximum memory-mapped file size.
    int st_maxopenfd;
    * Maximum open file descriptors.
    int st_maxwrite;
    * Maximum sequential buffer writes.
    db_timeout_t st_maxwrite_sleep;
    * Microseconds to pause after writing maximum sequential buffers.
    u_int32_t st_map;
    * Requested pages mapped into the process' address space (there is no available information about whether or not this request caused disk I/O, although examining the application page fault rate may be helpful).
    u_int32_t st_cache_hit;
    * Requested pages found in the cache.
    u_int32_t st_cache_miss;
    * Requested pages not found in the cache.
    u_int32_t st_page_create;
    * Pages created in the cache.
    u_int32_t st_page_in;
    * Pages read into the cache.
    u_int32_t st_page_out;
    * Pages written from the cache to the backing file.
    u_int32_t st_ro_evict;
    * Clean pages forced from the cache.
    u_int32_t st_rw_evict;
    * Dirty pages forced from the cache.
    u_int32_t st_page_trickle;
    * Dirty pages written using the DB_ENV->memp_trickle method.
    u_int32_t st_pages;
    * Pages in the cache.
    u_int32_t st_page_clean;
    * Clean pages currently in the cache.
    u_int32_t st_page_dirty;
    * Dirty pages currently in the cache.
    u_int32_t st_hash_buckets;
    * Number of hash buckets in buffer hash table.
    u_int32_t st_hash_searches;
    * Total number of buffer hash table lookups.
    u_int32_t st_hash_longest;
    * Longest chain ever encountered in buffer hash table lookups.
    u_int32_t st_hash_examined;
    * Total number of hash elements traversed during hash table lookups.
    u_int32_t st_hash_nowait;
    * Number of times that a thread of control was able to obtain a hash bucket lock without waiting.
    u_int32_t st_hash_wait;
    * Number of times that a thread of control was forced to wait before obtaining a hash bucket lock.
    u_int32_t st_hash_max_nowait;
    * The number of times a thread of control was able to obtain the hash bucket lock without waiting on the bucket which had the maximum number of times that a thread of control needed to wait.
    u_int32_t st_hash_max_wait;
    * Maximum number of times any hash bucket lock was waited for by a thread of control.
    u_int32_t st_region_wait;
    * Number of times that a thread of control was forced to wait before obtaining a cache region mutex.
    u_int32_t st_region_nowait;
    * Number of times that a thread of control was able to obtain a cache region mutex without waiting.
    u_int32_t st_mvcc_frozen;
    * Number of buffers frozen.
    u_int32_t st_mvcc_thawed;
    * Number of buffers thawed.
    u_int32_t st_mvcc_freed;
    * Number of frozen buffers freed.
    u_int32_t st_alloc;
    * Number of page allocations.
    u_int32_t st_alloc_buckets;
    * Number of hash buckets checked during allocation.
    u_int32_t st_alloc_max_buckets;
    * Maximum number of hash buckets checked during an allocation.
    u_int32_t st_alloc_pages;
    * Number of pages checked during allocation.
    u_int32_t st_alloc_max_pages;
    * Maximum number of pages checked during an allocation.
    u_int32_t st_io_wait;
    * Number of operations blocked waiting for I/O to complete.
    Please let me know if this helps.
    Thanks,
    Bogdan

Maybe you are looking for

  • How do I see NEXT month in the calendar?

    I've tried everything I can think of but I'm still stuck in April. I just wanted to see what day Cinco de Mayo falls on and I had to actually take out my phone. The horror.

  • Should I increase TEMP tablespace size here ?

    Version: 10.2.0.4 Platform : RHEL 5.8 Currently we are running a batch job in a schema. The default temporary tablespace for that schema is TEMP. But I see that the tablespace is full. SQL> select file_name, bytes/1024/1024/1024 gb from dba_temp_file

  • Excel 2007 HTML issue losing pictures on saving.

    We have an excel document that we download from a website and then save to the desktop. We then open the document and make changes then save we lose the pictures that were there previously. The strange thing is this was not an issue until we moved to

  • About function module

    "FM_SELECTION_CRITERIA_PRINT" What is its use ? There is documentation available in english.

  • What are the common errors in reporting and extraction.

    hi friends, what are the common errors in reporting and extraction for implementation and support projects. thanking u suneel.