Calculating average of non-zero values only

Hi all,
I have a table containing a numeric column which contains processing time in mili seconds. this can range from zero to any value. I want to calculate average processing time for only those entries which have non zero processing time in a single SQL. can you please suggest any SQL function for this?
I'm using Oracle 10g.

Sure, decode the 0 values to NULL (aggregate functions like AVG do not consider NULL values).
ME_XE?with data as
  2  (
  3     select 10 as col1 from dual union all
  4     select 0  as col1 from dual union all
  5     select 20 as col1 from dual union all
  6     select 20 as col1 from dual
  7  )
  8  select avg(col1) as col1_avg, avg(decode(col1, 0, null, col1)) as col1_avg_no_zero
  9  from data;
          COL1_AVG   COL1_AVG_NO_ZERO
              12.5 16.666666666666667
1 row selected.
Elapsed: 00:00:01.07
ME_XE?

Similar Messages

  • Display only non zero values  in rows

    Hi Friends,
                      I have a key figure "X', and it is split over 12 months (aging buckets), by using formula, but I want to filter values with zero values ie I want to display all non zer values only.
    This looks like
    Apr        100   
    May       200   
    Jun         200 
    Jul            0   
    Aug
    Sep
    Oct
    Nov
    Dec
    Jan
    Feb
    Mar
    In the above example I dont want to display 'Jul' at all, and the rest should be displayed, Wherein all the above are formula(Apr, May,......)
    Is it possible ?
    If so , what is method.
    I tried supress in query properties , Like supress zeros, but it is not working.
    Suggest me
    Points assured.
    Sanjay

    Dear Gupta,
                       In my case condition is not working, as I want to display values that ae non zeros. If I am using conditions, none of the values are displayed like Apr, May,Jun, Jul, etc........, I want to display all values except Jul as that values is zero as per my example.
    Please suggest
    Sanjay.

  • Non zero values in the extraction of the planning area

    In our DP implementation we have been trying to extract 2 key figures  from the planning area, one of the key figures might have zero values, when we set the indicator for the non zero values then it only eliminates the records for which both the key figure are zero but that is not what I want. I am trying to have a setting in the data source where we can reject the records even if one of the key figure has zero values.
    Are there any settings for that while we are generating the data source.
    Thanks in advance

    Hi Colin,
    This can be easily solved using a slightly different ABAP routine. You can assign the fields that you need to check into other field symbols and then check the value of those field symbols.
    Here's one possible solution. I based in from the ABAP code you posted.
    field-symbols: <LS_EXTR_BLOCK> TYPE any,
                         <ls_fcst> type any,
                         <ls_hist> type any.
    data: w_pos type sy-tabix.
    loop at ct_data assigning <LS_EXTR_BLOCK>.
    w_pos = sy-tabix.
    assign component '/BI0/9AVCORFCST'
       of STRUCTURE <LS_EXTR_BLOCK> to <ls_fcst>.
    assign component '/BI0/9AVCORHIST'
       of STRUCTURE <LS_EXTR_BLOCK> to <ls_hist>.
    if <ls_fcst> = 0 and <ls_hist> = 0.
      delete ct_data index w_pos.
    endif.
    endloop.
    Aside from the solution above, you can also define the structure of CT_DATA (that's basically the structure of the extract structure of your datasource). You can then assign the contents of CT_DATA to a field-symbol and the delete data using that field symbol.
    Here's an example:
    TYPES:
    TY_DATA_TABLE type table of *PUT THE NAME OF YOUR EXTRACT STRUCTURE HERE*.
    field-symbols:
    <FS_DATA_TABLE> type TY_DATA_TABLE.
    DELETE <FS_DATA_TABLE> WHERE /bi0/9avcorfcst = 0
    and /bi0/9avcorhist = 0.
    You can check the name of the extract structure by viewing table /SAPAPO/TSAREAEX field EXPORT_STRU. You can also see the name of the extract structure in debug mode by looking at the value of the parameter IV_DDIC_REFERENCE.
    Hope this helps

  • Display Non-zero values of keyfigures based on a particular value of a cha

    Hi Gurus,
    I would like to display only Non-zero values for keyfigures but only for a particular value of a characteristic. For Ex: We have material Group. For a particular value of material group, i do not want to display the zero stock. But for other material groups it should display zero stock.
    I tried to use conditions, but the problem is it suppresses all the zero values for the keyfigure for material group in general and not for a particular value of the material group.
    Is there is any way that i can go about for this scenario. Pls help.
    thanks & regards,
    PS

    Hi,
    You can very much restrict your KF on particular values of said material group. For example you material group contains the values like "Blades", "Personal Cares", "Disposables" etc... and you want to restrict your KF on "Blades" only, you can do that.
    Just restrict your KF on Material Group and include the values which you want for restrictions. You can also exclude values from restrictions.
    Hope it help you.
    Yogesh.

  • Display Non-zero values of keyfigures based on a particular value of a char

    Hi Gurus,
    I would like to display only Non-zero values for keyfigures but only for a particular value of a characteristic. For Ex: We have material Group. For a particular value of material group, i do not want to display the zero stock. But for other material groups it should display zero stock.
    I tried to use conditions, but the problem is it suppresses all the zero values for the keyfigure for material group in general and not for a particular value of the material group.
    Is there is any way that i can go about for this scenario. Pls help.
    thanks & regards,
    PS

    Hi
    Create a structure in the rows based on selections on material group. Eg.
    Structure
       Mat grp 1 (restricted to material during selection)
       Mat grp 2
    then add a formula in columns using boolean argument
    e.g (exisisting KF >= 1)*1+0
    Then you can use conditions to elimanate zeros on the new KF.
    Hope it helps
    Edited by: Karin van der Merwe on Feb 29, 2008 8:52 AM

  • How to Get ZERO and Non-ZERO Values in rowcount using Group by?

    Dear All,
    How can I get Non-ZERO and ZERO row count values in SQL using Group by? I can get non-zero values but when I want NULL should be returned to non-zero values it is ignoring ZERO values in output?
    Any hint?
    Thanks
    GQ

    Hi,
    Something like
    select count(case col
                    when 0
                    then 1
                  end) zero_count,
           count(case nvl(col,1)
                    when 0
                    then null
                    else 1
                  end) nonzero_countRegards
    Peter

  • How to find first non zero value from the numeric value or string?

    Hiii, Every body
              I have one numeric indicator in which some valuse is coming with the decimal value, lets say 0.00013, now i want to find the first non-zero value from this numeric indicator, then what should i do to do so? i have converted it in the string, but i could not find any method to find first non-zero value from that string or either from the numeric indicator????
          Can you please help me, how to do it? i have attached the vi and write all the description inside.
    Thanks in Advance,
    Nisahnt
    Attachments:
    Find first nonzero.vi ‏20 KB

    Just convert it to an exponential string and take the first character .
    Message Edited by altenbach on 05-10-2006 08:00 AM
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    FisrstNonzeroChar.png ‏3 KB
    FindFirstNonzeroCharacter.vi ‏20 KB

  • How to find average for non blank values

    I need to calculate avarage for each restricted key figures. There are some blank values in this restricted key figures. Now I need to sumup and divide by non blank count. Do you know how to do it? How to count non blnak values and find avereage.
    Thanks,
    Phani

    In the properties of Key figure used in column/row, Calculations section, you can maintain calculation type for result as well as single value. There is "Average of all values not equal 0" option is available.
    Rgds,
    Vikram.
    Edited by: Vikram Kate on May 22, 2008 11:23 AM

  • A new schedule line with net price zero but custom duty non-zero value

    Hello,
    I have a special requiremnet in MM scheduling agreement, for a specific type of scheduling agreement, I am copying a schedule line to a new schedule line. The new schedule line should have all the pricing and duty values from the old schedule line, except the net price of the new schedule line should be zero.
    I am able to make the net price zero in the new schedule line, but not able to copy the custom duty values from the old schedule line. Since my netprice is zero in the new line, it automatically set all other follwoing duty values also to zero.
    Say example a scheduling agreement: A has two line:
                                                                                    Condition Type           %                    Total Value
    scheduline line 1 -  with pricing values                  PB00                                                  200  USD                                                                               
    Cond1                         5                       10  USD
                                                                                    Cond2                        10                      20  USD
                                                                                    230  USD
    expectedd result i the new schedule line
    scheduline line 2 -                                                  PB00                                                  000  USD                                                                               
    Cond1                         5                       10  USD
                                                                                    Cond2                        10                      20  USD
                                                                                    30  USD
    I am trying to overwrite the condition values using the FM RV_CONDITION_COPY, but  I am not getting the desired result.
    Please let me know if you have any solution to my requirement.
    Best Regards,
    Amarjit Singh

    Hello Colleague;
                                                                                    In Standard the schedule lines cateogory CV is activated for 'Req./Assembly' and 'Availability'.                              
    Please, make this adjust and re-test you process.
    Regards
    Ruy Castro

  • Calculating average of selected values

    Hello all,
    I would like to put the following question in relation to bex queries:
    We have a condition in our query to select the 5 top values and the 5 bottom ones. But there are 33 values. When we calculate the average value (result of the query), we can do it in a way the query displays  the average of those 10 values displayed. But innerly the average value stored is the average of the 33 values (all) and in SEM that's the value we see (not the average of the 10 values selected.)
    And now, the question:
    Is there a possibility to obtain from SEM the average of the 10 values displayed?
    Thank you very much,
    Carlos Hinestrosa

    Hi Nick,
    Petri Net Method
    Researchers of Petri Nets from 1962 to about 1990 developed the main ideas (including the basic graphics notations) of the “thought process” I used. One of the literature I read on Petri Nets is the textbook (except for the chapters on Grafcet),
    David and Alla (1992). Petri Nets and Grafcet: Tools for Modeling Discrete Event Systems. New York: Prentice Hall.
    If you want to research the topic on your own, there is a bibliography on Petri Nets.
    Missed Requirement
    It occurred to me that we missed the possibility that a user can select a non-zero value given that a non-zero value is currently selected (T14 – T19) for each of the six fields. Here is the diagram with this requirement.
    Since we agree on the general interpretation of the diagram, I am combining several graphics to create a new, more concise diagram. Of course, this is a cryptic diagram to someone who do not agree with the earlier diagram.
    Additional Requirement
    We can also include the cumulative sum of the non-zero values selected by the user (P8), similar to the cumulative number of non-zero values selected (P6). In this case, a document-level variable for the cumulative sum should be defined, and updated along with counter. When the computation for the average is needed, the cumulative sum is already available and the average is computed by dividing the cumulative sum by the number of non-zero values selectes: m(P8) / m(P6) .
    If we do this, we would have done something very interesting: there are no for-loops in the code.
    Regards,
    John

  • Suppresion of NON-ZERO numbers in Key Figures

    Dear All,
    How do we suppress Non - zero values for multiple Key figures in Query Designer? Please suggest some method.
    I have tried conditions and it does not work for individual cells....It works for an entire row.....
    Thanks,
    Naveen

    But will that suppress the zeros too?? I want the Zero's to be displayed...only non-zeros to be suppressed....Please let me know if this is what it does...
    I dont see that option at all...in the properties
    thanks for your help
    Edited by: Naveen_Purdue on Sep 22, 2010 7:05 PM

  • Why disable few parameters when fast_start_mttr_target set to non zero.

    When fast_start_mttr_target set to non zero value why do we need to disable log_checkpoint_interval, log_checkpoint_timeout and fast_start_io_target?

    These parameters were replaced in 9i only by the fast_start_mttr_target parameter. And the recommendation to not to use them now is because, if set , these parameters would override the FSMTT parameter and also would disable the auto-tuning of the incremental checkpointing which is there because of FSMTT.
    HTH
    Aman....

  • Consumption value updated for zero value materials

    Hi Masters
    I have maintained value of a material in material master as zero.Although it is maintained zero, When the material is issued using 261 accounting document got generated and showin the following entries
      Inventory a/c
    Consumption a/c(+)
    How it is happening?
    Regards
    Mohan

    hi,
    Check your price control it would be MAP...
    REASON :
    Suppose you post the GR at price of 100/pc...where as in MMR the price is ZERO...
    Now when you post the GR at 100/pc...the MAP changes in the MMR automatically...ie. via total value / total stock...so the MAP doesn't remain ZERO now...
    So, now when you post the GI, the current MAP is taken from MMR ie. Non-ZERO value and so system post the accounting document while GI...
    I hope the matter is clear now..
    Regards
    Priyanka.P

  • How to consider only values 0 when calculating Averages

    Hi,
    Currently, I am using Avg (table.column) function to caluclate averages. However, one of our user wants to only consider records that are >0 when calculating averages. For example if a result set as 10 records, and only 2 of them has values >0 then typically Avg function would caculate based on (sum of 10 records/10). But per our user's requirement, he wants to consider (sum of 2 records/2) and ignore the remaining 8.
    Can you please tell me how to do achieve this?

    I found the solution after much deliberatiion myself :-). I used the following formula instead of the AVG function and it worked.
    Note that "Fact - +fact name+".column is a numeric column and can have null values.
    SUM(IFNULL("Fact - +fact name+".column, 0)) / COUNT("Fact - +fact name+".column)

  • Is there a way to not include zero values in sums and an average?

    I'm working on a new performace evaluation & would like to sum the score of each line, then get an average of the total scores.
    example:  stength (1 value), Solid Performer (2 value), Performer (3 value), Recommend Development (4 value), N/A (zero value)  then a total score of all the values, not including the zero value. 
    Then an average score of all the scores given.
    Hope this makes sense! 
    Thanks in advance for the input!!!

    If you use the calculation option "The field is the ____ of the following fields:", nulll values and zero values are included as zero and the number of number of items use is the number of fields selected.
    If you want a different calculation, then you will have to write a custom script to sum and count the fields you want to include in the calculation.

Maybe you are looking for

  • Out of Stock  items

    When creating a sales order , Is it possible for the item availability check to show items which are out of stock? Clients request is as follows: This is the box (item availability check ) that I am after, at the moment it pops up when we try to put

  • Actual Cash Discount ?

    Dear Expert, Are there anyway to do the discount in the Incoming Payment under BANKING as the "actual cash discount" instead of cash discount%? Thank you.

  • Java image in html

    i hav created a jpg file using java... i need to use that file to display it in a table cell in html... how can i do that...

  • Online Number is already being used by some other ...

    Hi, I have bought an online number yesterday 19th June, and after the subscription got activated, I got to know that this number is already in use with some other company. When I dial the same skype online number it rings in some other company's call

  • How do I delete just the old history (2013) and leave the rest

    I need to delete all my ancient history, but not the recent. Can't find any way to select by date. Win 7 Home Premium Ninian