Calculations of average growth rate

Hello

I have three columns in a table as follows:
col1       col2        col3
UO      1-JUL-2012      400
UO      1-JUN-2012      300
UO      1-MAY-2012     350
GE      1-JUL-2012       700
GE      1-JUN-2012       600
GE      1-MAY-2012      400
MS      1-JULY-2012     50
MS      1-JUN-2012       40
MS      1-MAY-2012      80

I would like to get an average growth per month as follows. A nudge in the right direction is very much appreciated.

col1  col2
UO   Avg for UO
GE   Avg for GE
MS   Avg for MS
Thank you
-Abe

Published by: abe50 on July 19, 2012 15:26

abe50 wrote:
I subtract the maximum value of the min value and divided by the number of months. In this case, three months.

Assuming that the date is always the first of the month:

with data as (
              select 'UO' col1,to_date('1-JUL-2012','DD-MON-YYYY','NLS_DATE_LANGUAGE=AMERICAN') col2, 400 col3 from dual union all
              select 'UO',to_date('1-JUN-2012','DD-MON-YYYY','NLS_DATE_LANGUAGE=AMERICAN'),300 from dual union all
              select 'UO',to_date('1-MAY-2012','DD-MON-YYYY','NLS_DATE_LANGUAGE=AMERICAN'),350 from dual union all
              select 'GE',to_date('1-JUL-2012','DD-MON-YYYY','NLS_DATE_LANGUAGE=AMERICAN'),700 from dual union all
              select 'GE',to_date('1-JUN-2012','DD-MON-YYYY','NLS_DATE_LANGUAGE=AMERICAN'),600 from dual union all
              select 'GE',to_date('1-MAY-2012','DD-MON-YYYY','NLS_DATE_LANGUAGE=AMERICAN'),400 from dual union all
              select 'MS',to_date('1-JULY-2012','DD-MON-YYYY','NLS_DATE_LANGUAGE=AMERICAN'),50 from dual union all
              select 'MS',to_date('1-JUN-2012','DD-MON-YYYY','NLS_DATE_LANGUAGE=AMERICAN'),40 from dual union all
              select 'MS',to_date('1-MAY-2012','DD-MON-YYYY','NLS_DATE_LANGUAGE=AMERICAN'),80 from dual
             )
select  col1,
        (max(col3) - min(col3)) / (months_between(max(col2),min(col2)) + 1) avg_growth
  from  data
  group by col1
/

CO AVG_GROWTH
-- ----------
UO 33.3333333
GE        100
MS 13.3333333

SQL> 

SY.

Tags: Database

Similar Questions

  • Query to retrieve the average growth rate

    Hi all

    10.2.0.5 on solaris

    Table script:

    DB_SPACE_HIST
    (
    DATE TIME STAMP,
    TOTAL_SPACE NUMBER (8).
    USED_SPACE NUMBER (8).
    FREE_SPACE NUMBER (8).
    PCT_INUSE NUMBER (5.2).
    NUM_DB_FILES NUMBER (5)
    );

    Sample data:


    Timestamp: / 16/2010 12:57:52 AM
    Totak space: 678017
    Used space: 235612
    Free space: 442405
    PCT in use: 34.75
    number of files: 60


    We have the timestamp stored in the table for more than 3 years. The requirement is that we get the average growth in the database per month.

    No idea how I can do this?

    Kai

    Start by getting your data used_space by month:

    select
    trunc(timestamp,'MM') mth,
    max(used_space) used_space_end_mth
    from db_space_hist
    group by
    trunc(timestamp,'MM');
    

    Then you can use the analytic function LAG to get used_space_end_mth compared to the month previous for calculating growth:

    select
    mth,
    used_space_end_mth - lag(used_space_end_mth) over (order by mth) growth
    from (
       select
       trunc(timestamp,'MM') mth,
       max(used_space) used_space_end_mth
       from db_space_hist
       group by
       trunc(timestamp,'MM')
    )
    order by
    mth;
    

    And finally, you can simply select the average growth:

    select
    avg(growth) avg_growth
    from (
       select
       mth,
       used_space_end_mth - lag(used_space_end_mth) over (order by mth) growth
       from (
          select
          trunc(timestamp,'MM') mth,
          max(used_space) used_space_end_mth
          from db_space_hist
          group by
          trunc(timestamp,'MM')
       )
    );
    
  • Create a custom attribute to model the growth rate of the data store used space

    I would like to see data warehouses are growing fastest of the environment in terms of GB per day or something similar.  Is it possible to use a custom attribute to apply a formula that measures the rate of growth of a store of data over time, which allows me to see what data stores fastest?

    You would look for an average simple mobile for a SM you describe. vC Ops does not simple moving average formulas for SMs at this time.

    Looks like you are looking for a "growth rate", but you really won't get it with the built-in attributes. You might look differently and look at the remaining capacity and the remaining time metric. Also, you could create additional widgets to view graphs of util % over the last 30-90 days to give a better picture of usage in GB, #VMs, etc.

    I also suggest to make a Top - N showing use the lowest of the remaining time metric and the remaining ability... This will give you your data warehouses that are more at risk.

  • How to calculate the month on month growth rates in an OBIEE application?

    Hi all

    I would like to ask for your help on how to calculate the months on growth rate previous/[(last month-previous month) month * 100%] in a query OBIEE. This report should always be calculated for the last 2 months available.

    I have the following query:
    Month0 | Months1. Month2
    Produces a 500 | 100. 200
    Product B 600 | 300. 150

    I would like to add month on month column as follows:
    Month0 | Months1. Month2. Month on Month (%)
    Produces a 500 | 100. 200 | + 100.00%
    Product B 600 | 300. 150. -50.00%

    I tried to add a calculated item, but it failed because I couldn't find a way to not show the column calculated in percent with 2 decimal places. In addition, I would ideally prefer to have an automatic update but as far as I understand it can be done in the automatically calculated item

    I also tried to add a new column to the column area and to filter the results for the last month, then for the previous month and then based on that to calculate the necessary ratio but unfortunately it does not work.

    Thank you in advance your advice

    Hello

    The best way to solve this problem is by using the function Ago. With this, you can create a logical column for the previous month. Then you will have 2 columns available with which you can do your calculations.

    If you want to do this with a calculated item (don't know if formatting will work for you), but you can do the more general calculation using $1 for the $2 for the 2 column and 1 column in your calculation. If ($x) columns will change with the columns in your report.

    Concerning

  • Calculate the & quot; Compound annual growth rates & quot;.


    I'm trying to calculate the compound annual growth rate. I know what the forumla is (see link below), but cannot work out how to make this calculation in Cold Fusion... that works to use or how to string together them.

    At the hope that someone with a little more experience with SFC mathematical functions could help.

    The formula, I'm figuring in CF are at: http://www.investopedia.com/terms/c/cagr.asp

    Thanks a lot in advance to the genius who can help me to crack this one.

    See you soon



    Hope that makes sense!

  • When I do a race with my Apple Watch I don't have a frequency heart displayon the session screen. When I then sync my activity with my iphone there is also no average heart rate on the completion of my activity. How can I get my heart rate displayed?

    When I do a race with my Apple Watch I don't have a frequency heart displayon the session screen. When I then sync my activity with my iphone there is also no average heart rate on the completion of my activity. How can I get my heart rate displayed?

    Hello

    Mode power saving can be activated.

    To check this, on your iPhone, in the application of the watch, go to: Watch My > Workout - if it is currently enabled, disable power saving Mode.

    (When the power saving Mode is enabled, it disables the sensor of heart rate during workouts running).

  • Average heart rate at rest?

    Y at - it an easy way to calculate your average (non-exercise heart rate at rest as an indicator of fitness shaped over time?

    In health, I can say ranges heart rate at various points, and even a list of each heart rate recorded at throughout the day, but have not yet found a way to use measures of heart rate watches Apple to give me a reading on my average heart rate at rest. Assuming that it is simply a GIANT omission by apple, all third party app recommendations would be appreciated.

    Hi Steven

    For example, you can find the following useful third-party application:

  • How moniter "growth rate" and "-amount of increase" segments?

    Hi all.

    I want to moniter 'uncreated-rate' and 'uncreated-amount' of the database segments.

    Y at - it no oracle dictionary that would help me to moniter "growth rate" and
    "- amount of increase" data segments?

    I studied the CWA the dictionary-based, but I could not find.

    The version of oracle is 10.2.0.4.0.

    Thanks in advance.
    Best regards.

    If the arrays are defined MONITORING (which should be the default in 10.2, if memory serves), a count approximate to the number of rows inserted, updated and deleted since the statistics were collected last should be in DBA_TAB_MODIFICATIONS.

    I'm not clear, however, why you have turned off the automatic statistics collection work. Looks like you have turned off the job and are now trying to rewrite the option GATHER STALE. Who collects statistics on objects automatically only if DBA_TAB_MODIFICATIONS shows that a substantial fraction of rows have changed. If you have very large tables, it must be very rare that GATHER RASSIS option would choose collect statistics because it would take a very large number of changes to cause the Oracle to review the outdated statistics.

    Justin

  • Calculation of average in the child-parent relationship

    Hello

    Oracle database version: 11.2.0.1.0

    Currently I'm having a problem of query to calculate the average value. Using the usual average query does not get the result I'm looking for. Because I'm not good with English, I will try to explain for example instead.

    Data table
    COD_A     COD_B     SALES     QTY     PRICE
    0000302     00003               6.09
    0000302     00003               11.7
    0000304     00003               14.08
    0000306     00003               8.87
    0000306     00003     3105     510     4.63
    0000306     00003               4.65
    0000308     00003     18091     1456     12.43
    If I try to calculate the average price of COD_A, I have the correct answer, as expected.
    SELECT COD_A, SUM(SALES), SUM(QTY), AVG(PRICE) FROM VDATATABLE GROUP BY COD_A ORDER BY 1;
    Average price per COD_A
    COD_A     SUM(SALES)     SUM(QTY)     AVG(PRICE)
    0000302                                8.895
    0000304                           14.08
    0000306     3105         510                6.05
    0000308     18091        1456              12.43
    --------------

    If I try to calculate the average price of COD_B, I don't have my expected result.
    SELECT COD_B, SUM(SALES), SUM(QTY), AVG(PRICE) FROM VDATATABLE GROUP BY COD_B ORDER BY 1;
    Average price per COD_B (1)
    COD_B     SUM(SALES)     SUM(QTY)     AVG(PRICE)
    00003     21196             1966              8.92142857142857
    The result I'm looking for is
    WITH W1 AS
    (SELECT COD_B, SUM(SALES) SALES, SUM(QTY) QTY, AVG(PRICE) PRICE FROM VDATATABLE GROUP BY COD_A,COD_B)
    SELECT COD_B, SUM(SALES), SUM(QTY), AVG(PRICE) FROM W1 GROUP BY COD_B;
    Average price of COD_B (2)
    COD_B     SUM(SALES)     SUM(QTY)     AVG(PRICE)
    00003     21196              1966         10.36375
    ---------

    So, the way I want to calculate the average price is the average of the lower child attribute and continue the average to its parent attribute. Currently I can get the result by using the clause, but the hierarchy available not only stops at COD_B, there is more (e.g. COD_C, COD_D, so on), so the foregoing WITH the query "seems" to be inflexible. If I want to ask the COD_C aggregation, I might have to put another COMPONENT in the query.

    So I was wondering is there any other better method to get the result I want? Something more dynamic as a recursive function or integrated maybe?

    Thank you

    Published by: user10620897 on October 19, 2011 04:15

    Hello

    Whenever you have questions, please post CREATE TABLE and INSERT statements for your sample data.
    Always tell what version of Oracle you are using. Don't say something vague, like "11g" in a label where it is easy to miss. Tell exactly what version you have in the body of the message. For example "I'm using Oracle 11.1.0.7.0.

    If you have N levels in the hierarchy, then using subqueries N-1, as you already do, might be the best way.

    If you use Oracle 11.2, you may be able to obtain these results by using a WITH recursive clause.

    Here's another approach to obtain the results desired with a hierarchy of level 2:

    WITH     got_cnt          AS
    (
         SELECT     cod_a, cod_b, sales, qty, price
         ,     COUNT (*) OVER (PARTITION BY cod_a, cod_b)     AS cnt
         FROM     data
    )
    SELECT       cod_b
    ,       SUM (sales)               AS sum_sales
    ,       SUM (qty)                  AS sum_qty
    ,       SUM (price / cnt)
           / COUNT (DISTINCT cod_a)     AS avg_price
    FROM       got_cnt
    GROUP BY  cod_b
    ;
    

    I think you can do this job for any number of levels without adding another subquery for all levels. You may need to add expressions to COUNT more for all levels, and the query only works for a fixed number of levels.

  • Calculation of average (average) of a number of entries by the user?

    I'll try to find a script that calculates the average (mean) of the data entered by the user, the user can enter anywhere between the values of number 1 to 6.  That's what I tried in FormCalc:

    DCount var = 1;

    If Row3.Cell6! = null then (DCount = dcount + 1);

    If Row4.Cell6! = null then (DCount = dcount + 1);

    If Row5.Cell6! = null then (DCount = dcount + 1);

    If Row6.Cell6! = null then (DCount = dcount + 1);

    If Row7.Cell6! = null then (DCount = dcount + 1);

    (Row2.Cell6 + Row3.Cell6 + Row4.Cell6 + Row5.Cell6 + Row6.Cell6 + Row7.Cell6) / dcount

    I also tried

    If HasValue (Row3.Cell6) then (DCount = dcount + 1);

    etc.

    But I get a syntax error in both cases.  How can I fix the script so as that does this that I need to?

    AVG (Row3.Cell6, Row4.Cell6, Row5.Cell6, Row6.Cell6, Row7.Cell6)

    Tip: If you name your lines the same (ex RowA) you can just put: Avg (RowA [*]. Cell6) that your code

    Kyle

  • average rate of table 1 d change

    IM frustrated against myself, because it seems like it would be very simple and I'm stuck.

    I have a table 1 d of values. I'd like calculating the average rate of change for each set of 11 items. I've already calculated by hand what im waiting and all ive tried in labview is not pair, I tried the registers derived from function and change. Perhaps I used the wrong shift registers, because I am fairly new with their use.

    Could someone offer some tips or examples? Much appreciated, as always.

    Try something like this:

  • calculation of the average value of the sorted data and polar route drawing

    Hello

    I did a VI that calculates the average value of the wind rotor/speed-ratio in the sections of 30 degrees (wind direction). He also called the polar plot of calculated data. Everything works, but I would like to make more detailed calculations and drawings, by increasing the resolution to 1 degree, or...

    Problem is VI, I did, is not easy on a large scale. At the moment, I have 12 parallel structures of switch-box to calculate the average value and build the array function to collect data calculated for Polar plot to draw the image in real time. I know it's probably the worst way to do it, but since I have done a few things with LV, it was the only way I managed to do what I wanted.

    Now, if I continue in same way to reach my goal, I have to create 360 Parallels switch-case structures... that are crazy.

    Something like the calculation of the average of the table or matrix (zero/empty values should not be calculated on average) inside the loop or similar way would probably be the best solution.

    So, polar plot drawing is not a problem, but creating a reasonalbe average metering system is. Any ideas?

    I would also like to rotare northward to the top (0 deg), and degrees of increase in a clockwise direction on polar ground dial plate (as on the compass).

    VI on the attachment. (simplified version of the complete system)

    I have signals:

    -Wind speed

    -wind direction

    -Rotor speed

    I want to:

    -calculate the average value of the speed of the wind / rotor - ratio in sections (5 degrees, 1 degree)

    -Draw a polar path of the wind rotor/speed-ratio of averages in propotion of wind direction

    I'm using LabView 2009

    Thank you very much.

    It is closer to what you're looking for?

  • Calculation of signal to noise ratio

    Hello.

    I was wondering if it was possible to calculate the SNR of a signal with LabView? I use a DAQ hardware and an accelometer to measure a force.

    Is that being said, possible to calculate SNR by looking at the graph of spectrum or vague? When there is no g on the accelerometer, there is a signal with a little noise... and I can see that in the spectrum of frequecny all the way to the cut-off frequency. What is the background noise?

    I'd appreciate any help!

    Thank you!!

    Abraham_E,

    Thanks for the data.  Curiously, the data do not seem to care what language you were using when you got it.

    The first data column appears as timing information.  The dt in who is 0.0005, which corresponds to a frequency of 2 kHz.  You said 400 Hz in one of your messages.  The discussion at the point 2 below corresponds to a frequency of 2 kHz sampling.

    1. you are right that SINAD is not very useful. SINAD assumes that all the power of the signal is the dominant frequency component that is not quite true for ECG.

    2. the size of the FFT of the signal shows the dominant signals at 50 and 100 Hz which is likely to be able to line with frequency. Al here also erase lines 200 and 250 Hz. You certainly do not want to calculate SNR under the assumption that the desired signal is 50 Hz.  The SINAD VI calculates the fundamental frequency than 49,97 Hz.

    3. If you don't know the 50 Hz and harmonic components, there is no obvious lines in the spectrum remaining. I interpret this means you have the significant variation of heart rate data.  This means that the heart rate is modulated in frequency. Frequency modulation broadens the spectrum.

    4. because there is not predominant in the spectrum, it is unlikely that frequency domain techniques will be worth any in the determination of the SNR.

    So, what can you do? Looking at the data graphic, I think a peak signal to noise power ratio could be significant. There are little noise, even at spikes, if it has a few problems too.  I have divided the data set in 1 second segments. For heart rate in these data, each segment contains one or two beats.  In each segment, I found the maximum and minimum values.  I set the value from Ridge to Ridge for the segment of the difference. I also calculated the RMS value for the entire segment. Then the SNR is the signal from Ridge to Ridge divided by the RMS value. It is probably more accurate to use the RMS value of the QRS and exclude parts QRS of the RMS of noise, but to do both is algorithmically and by the much more difficult calculation. It would be also better force segments contain exactly one beat of each. Again, it is much more complicated.  I then calculated the average of the SNR segment values and call it mean SNR.

    As I pointed out, there are some problems with the definition (peak to peak/RMS).  If you just want to compare signals within your lab to see which improves things, this should be good.  If you want to publish data and compare to other published results, you have to find how they define and measure SNR.

    In the attached VI I read the file once and recorded values in an array as a default value. Then I removed the file played screws and just worked with the data. To try this with other data simply insert read VI file in the appropriate place.

    Lynn

  • Output DAQ savings at a lower sampling rate

    Hi all

    I'm relatively new to labview and all its features. The problem I've seen is that I don't know how to sample a continuous signal again. This is my problem, the assistant LabView DAQ samples continuously at 1 KHz so that the voltmeter is smooth as voltage changes. I don't want to have to record every 1000 data points every second even if in the .csv, so I tried many different ways to "resample" the data at a given rate of about 1-10 Hz.

    So far, I tried to use the loop of the timer, I don't know how well it works, and it didn't get me very far. I also tried to set all the values in an array of a specified size (with respect to the sample hz), take the index 0, delete it and begin to fill the table again. This kind of worked, but not at all how I wanted.

    Sorry that I can not provide photos or a vi like I changed it so many times he doesn't seem something like what I tried before.

    Assistance in this area would be very appreciated,

    See you soon

    Microtechno

    Use a shift to the filenme register.

    You didn't post your code so I don't know how you have the DAQ Assistant set up. You would get a writing all data to data acquisition whenever writing file is called. If you want only a scalar value of the DAQ Assistant, doing something as simple as calculating the average of the signal.

  • Features using different exchange rates for consolidations?

    There are two hierarchies of entity within our structure of metadata, and our parent company is GBP.

    The first hierarchy of entity is an entity in EUROS, and when assets are consolidated to change parent is correctly calculated at the closing rate of Exchange.

    The second hierarchy of entities contains another entity in EUROS, and this translates to the parent currency does not calculate correctly and to aid and exchange rate which is not is the closing rate, or an average rate for the period.

    There is no translation rule in our rules file.
    The metadata for the entities are formed with DefCurrency in EUR and both have direct relatives like GBP.
    Accounts which are being translated have all two AccountTypes defined as ASSET accounts.

    Someone has ideas on what can cause strange translations rates?

    Thank you

    Luke

    Empty rules and return to default consolidation rules temporarily. If the rates are only those in [none] and entities use the same currency, the rate of translation and method for the same account must be exactly the same. It is possible that, after translation that another rule interferes with the value you see. Empty out the rules and this will eliminate the possibility that another rule changes the value that you perceive as a different exchange rate.

    -Chris

Maybe you are looking for

  • Search suggestions is enabled but does not work?

    The search bar in the "Awesome bar" has recently ceased to offer suggestions from research or from my search history Google itself. When I control-click in the search bar, "search suggestions" has a check mark next to it, and it is also checked in th

  • How can I activate full? (for Pages 5.6.1)

    I don't know if I never noticed this before or if I was doing something without realizing it, but now my computer will not autocapitalize the first letter of each sentence. Is it possible to allow the autocapitalize text in Pages?

  • 500 a82in: 3.0 ports does not...

    Please get my 3.0 drivers...Are PCI IdPCI/VEN 1022 & DEV_7814 & SUBSYS_2B05103C & REV_01PCI/VEN 1022 & DEV_7814 & SUBSYS_2B05103CPCI/VEN 1022 & DEV_7814 & CC_0C0330PCI/VEN 1022 & DEV_7814 & CC_0C03There are yellow exclamation point in Device Manager.

  • Re: Satellite L550 - cooling fan suddenly stopped working

    About two weeks ago, I placed my laptop down on the ground. When I picked up two minutes later, there was an error on the screen that read something like "there is a problem with the cooling system, please contact your nearest centre of Toshiba. Sinc

  • give the user local administrator rights using local admin script

    I would like to give a domain user with local administrator rights using scripts via sccm, now that user does not disconnect, and if the admin rights come into force. I want to get the user who is logged on rights and it shall take effect as it is co