Moving average about the last x records

Hello,
I have a question regarding moving average calculation. The query contains information about tools, the date of the tool's breakdown and the quantity of produced parts with this tool.
Now I want to have an moving average over e.g. 3 tools back from the actual line.
1) Tool 1 - 2007-05-16 - 6.000   pieces - Average: 10k8k6k / 3 = 8.000
2) Tool 2 - 2007-05-13 - 8.000   pieces - Average: 9k10k8k / 3 = 9.000
3) Tool 3 - 2007-05-03 - 10.000 pieces - Average: 5k9k10k / 3 = 8.000
4) Tool 4 - 2007-04-24 - 9.000   pieces - Average: 9.000+5000 / 2 = 7.000
5) Tool 5 - 2007-04-03 - 5.000   pieces - Average: 5.000 / 1 = 5.000
Is this possible in BI 7.0?
Best regards,
Michael

Hi
Refer this
How to implement moving average key figure?
They are solving the same problem
Regards
N Ganesh

Similar Messages

  • How can I get the last / newest record of a table?

    Hi,
    I am developing an ecard app that has a create greeting page, a preview page with edit and send buttons and an edit page.
    I got he insert working, and on the preview page I created a master record page (displays all records), and delete all unecessary designs. Doing it this way also gives me the 'edit' button, so people are able to edit their page.
    How do I get only the last record displayed though? At the moment it loops through all records and displays them in sets of 10. I found the variable that holds the totla count of records ('$totalRows_rs7417_content1'), but how do I (re-)write the script so it ONLY diplays the last record?
    I need to get the ID of this record as I am writing this into the PARAMs of the object and embed tags of my message .swf (this picks up the ID and based on that sucks the greetings text out of the database via another php script.
    Also, from this page, how can I send an email to the sender (ie creator of the message) as well as the recipient? Both email addresses are in the databse so should be part of the erecord returned.
    Thanks,
    Nik

    -----
    OK, So how do I recreate what I got in a non-ADDT list?
    well, when you´re just about to display one certain record, the term "list" is somewhat inappropriate anyway.
    What you´d simply need to do IMHO, is using DW´s native functions to create the basic "SELECT * FROM table_name ORDEr BY ID DESC" query, add "LIMIT 1" manually, and display the desired "dynamic text" placeholders in 1 table cell -- don´t think there were any need for all the fancy stuff
    (sorting, filtering etc) provided by ADDT´s list, as it´s just 1 record.
    It also occurred to me just now that finding the last record that has been added *may-* notbe enough if the site gets used a lot by our executives (I am thinking of a situation where 2 or three peolpe create greetings at the same time and press submit and then getting each others messges rather than their own).
    in this case you might want to additionally store the respective executive´s "kt_login_id" session variable -- because it´s this unique "identifier" which should be used to show the last inserted record of the person who actually inserted it, means adding a "WHERE submitter_id" equals the session variable kt_login_id - clause to the query.
    When creating a non-ADDT list that´s at some point based on detecting a user session, you´ll BTW need to insert at line 1
    I can't seemt o insert it on the page as it is looking for a insert, update or delete bahaviour on the page which of course I don't have
    please search these forums for several posts I made which explain my "use dummy table" approach that´s made for cases when you actually don´t have anything to insert/update/delete, but need "something" for ADDT´s send email behaviours.
    Cheers,
    Günter Schenk
    Adobe Community Expert, Dreamweaver

  • Retrive a record before the last inserted record

    Hi,
    I use simple select statement to retrive records where cola = 'Yes':
    select * from tbl1
    where cola = 'Yes';
    The result gives me about 10 records with different date.
    From the above result, I want to get the record right before the last inserted record according to the date field; which means I can not use MAX function (all I want just one record).
    If I write a function to return a date and passes it back to the SELECT statement, I'll get a date for each record, which I don't want.
    I know there's a way to do that in PL/SQL.
    Plese help me.
    pem

    select * from (
    select * from
    (select * from (select * from (table> order by <date> desc) where rownum < 3)
    order by <date>) where rownum =1

  • Getting the last 5 records

    I was told I should do this by date, and not buy a number. He might still be right that by date is better. But I thought that by ticketnr makes also sense, because the latest ticket, is wel normally the most recent one. I've added the check although it might not be needed, so I may remove it later.
    The idea behind it is that if, although a field that needs to be filled in would give an error if not being so, a field that needs to be filled in, isn't then that record can't be used. As that wouldn't be the case, I can remove that as well. That would make it less complex.
    The idea was that records could have been deleted, so that you get 1185 1187 1188 1189 1190 . If you just take the 5 highest ticket numbers, you would only get 4 as one is missing. So I thought that if you include a check that check if the ticketid actually used or not. I suppose it would be nicer if one could write something similar to but therefore not the same:
    if tikcetid(select ticketid into ticketidtotest from ticket where ticketid=tussenticketid;).used() = TRUE then;
    Then you would be sure it is used, and it would just pick out the last 5 ones. There could be a problem with the dates if they are mixed up, but this could be a problem not just for this. So I think it would deserve a solution on the database.
    I'm getting one error as it is now.
    Error report:
    ORA-06550: line 83, column 20:
    PLS-00103: Encountered the symbol "=" when expecting one of the following:
    . ( * @ % & = - + < / > at in is mod remainder not rem then
    <an exponent (**)> <> or != or ~= >= <= <> and or like
    between || multiset member SUBMULTISET_
    06550. 00000 - "line %s, column %s:\n%s"
    *Cause:    Usually a PL/SQL compilation error.
    *Action:
    This is about the last : Tussen_ticketid := Tussen_ticketid - 1; But isn't it normall like it stands there ?
    DECLARE
    Mrecent_ticket NUMBER;
    Tussen_ticketid NUMBER;
    Ticketid_Place2 NUMBER;
    Ticketid_Place3 NUMBER;
    Ticketid_Place4 NUMBER;
    Ticketid_Place5 NUMBER;
    Ticketid_Place1 NUMBER;
    TestVeld VARCHAR2(2000);
    Query_to_use VARCHAR2(4000) := ' SELECT ticketid, applicatiecd, '||
    ' categorieid, titel, klantprioriteitid, interneprioriteitid, gebruikerid, statusid,'||
    ' versieid FROM ticket WHERE ticketid =';
    Start_Rec_ticketid NUMBER;
    TestVeldFoundThatIsCorrect NUMBER; is NULL; BOOLEAN := FALSE;
    BEGIN
    -- TestVeldFoundThatIsCorrect := FALSE;
         SELECT Max(Ticketid) INTO Mrecent_ticket FROM Ticket ;
         Tussen_ticketid := Mrecent_ticket;
         -- of dit echt nodig is weet ik zo niet
         -- kan eventueel opgevangen worden in de hoofd loop
         -- TestVeldFoundThatIsCorrect := FALSE;
         -- mischien checken op datum die ingevuld is, die moet ingevuld zijn wil het ok zijn
         LOOP From top to bottom  Till TEstVeldFOUNDTHATISCORRECT is TRUE
         WHILE TestVeldFoundThatIsCorrect != 9999999 LOOP
                   SELECT titel INTO TestVeld FROM ticket WHERE ticketid =
                   Tussen_ticketid;
              IF TestVeld is NULL THEN
                   Tussen_ticketid := Tussen_ticketid - 1;
                   TestVeld := NULL;
              ELSE
                   TestVeldFoundThatIsCorrect := 9999999;
                   Start_rec_ticketid := Tussen_ticketid;
                   --Stop loop
              END IF;
         END LOOP;
         IF TestVeldFoundThatIsCorrect = 9999999 THEN
              Tussen_ticketid := Start_rec_ticketid;
              -- standaard is het onderstaande, bovenstaande gebeurt alleen als de bovenstaande loop
              -- gebruikt is
         ELSE
              Tussen_ticketid := Mrecent_ticket;
         END IF;
         -- mischien moet er nog een count gebeuren die kijkt hoeveel tickets er zijn in een bepaalde --
         -- periode en afhankelijk daarvan, tussen wanneer en wanneer een andere flag zetten
         --LOOP TELLER BETWEEN 1 AND  6
         While teller <= 5 LOOP
              SELECT titel INTO TestVeld FROM ticket WHERE ticketid = Tussen_ticketid;
              --Veld_dat_ingevuld_moet_zijn INTO  TestVeld FROM ticket WHERE ticketid = Tussen_ticketid;
              -- dit zou het datumveld moeten zijn
              IF TestVeld is NOT NULL THEN
                   -- dan is dat record ok voor gebruik
                   -- wel nog nakijken welke veld dat moet zijn, moet altijd ingevuld zijn
                   -- waarde doet er niet toe
                   --Query_to_use := Query_to_use || ' UNION SELECT ticketid, applicatiecd, '||
                   --' categorieid, titel, klantprioriteitid, interneprioriteitid, gebruikerid, statusid,'||
                   --' versieid FROM ticket WHERE ticketid = ';
                   IF Teller = 1 THEN
    Ticketid_place1 := Tussen_ticketid;
    Query_to_use := Query_to_use || 'Ticketid_place1';
                   ELSIF Teller = 2 THEN
    Ticketid_place2 := Tussen_ticketid;
    Query_to_use := 'UNION'||Query_to_use || 'Ticketid_place2';
                   ELSIF Teller = 3 THEN
    Ticketid_place3 := Tussen_ticketid;
    Query_to_use := 'UNION'||Query_to_use || 'Ticketid_place3';
                   ELSIF Teller = 4 THEN
    Ticketid_place4 := Tussen_ticketid;
    Query_to_use :='UNION'|| Query_to_use || 'Ticketid_place4';
                   ELSIF Teller = 5 THEN
    Ticketid_place5 := Tussen_ticketid;
    Query_to_use :='UNION'|| Query_to_use || 'Ticketid_place5';
                   ELSIF Teller = 6 THEN
                        Teller := Teller + 1;
                   END IF;
                   Teller := Teller + 1;
                   Tussen_ticketid := Tussen_ticketid - 1;
              ELSIF
                   Tussen_ticketid := Tussen_ticketid - 1;
              END IF;
         END LOOP;
         -- dbms_output.Put_line(Query_to_use);
         RETURN Query_to_use;
    END;

    DECLARE
    Mrecent_ticket NUMBER;
    Tussen_ticketid NUMBER;
    Ticketid_Place2 NUMBER;
    Ticketid_Place3 NUMBER;
    Ticketid_Place4 NUMBER;
    Ticketid_Place5 NUMBER;
    Ticketid_Place1 NUMBER;
    TestVeld VARCHAR2(2000);
    Query_to_use VARCHAR2(4000) := ' SELECT ticketid,
    applicatiecd, '||
    ' categorieid, titel, klantprioriteitid,
    interneprioriteitid, gebruikerid, statusid,'||
    ' versieid FROM ticket WHERE ticketid =';
    Start_Rec_ticketid NUMBER;
    TestVeldFoundThatIsCorrect NUMBER; --is NULL;
    --BOOLEAN := FALSE;
    EGIN
    -- TestVeldFoundThatIsCorrect := FALSE;
    Max(Ticketid) INTO Mrecent_ticket FROM Ticket ;
    ussen_ticketid := Mrecent_ticket;
         -- of dit echt nodig is weet ik zo niet
         -- kan eventueel opgevangen worden in de hoofd loop
         -- TestVeldFoundThatIsCorrect := FALSE;
    -- mischien checken op datum die ingevuld is, die
    e moet ingevuld zijn wil het ok zijn
    LOOP From top to bottom  Till
    l TEstVeldFOUNDTHATISCORRECT is TRUE
         WHILE TestVeldFoundThatIsCorrect != 9999999 LOOP
    SELECT titel INTO TestVeld FROM ticket WHERE
    ERE ticketid =
                   Tussen_ticketid;
              IF TestVeld is NULL THEN
                   Tussen_ticketid := Tussen_ticketid - 1;
                   TestVeld := NULL;
              ELSE
                   TestVeldFoundThatIsCorrect := 9999999;
                   Start_rec_ticketid := Tussen_ticketid;
                   --Stop loop
              END IF;
         END LOOP;
         IF TestVeldFoundThatIsCorrect = 9999999 THEN
              Tussen_ticketid := Start_rec_ticketid;
    -- standaard is het onderstaande, bovenstaande
    de gebeurt alleen als de bovenstaande loop
              -- gebruikt is
         ELSE
              Tussen_ticketid := Mrecent_ticket;
         END IF;
    -- mischien moet er nog een count gebeuren die kijkt
    t hoeveel tickets er zijn in een bepaalde --
    -- periode en afhankelijk daarvan, tussen wanneer en
    n wanneer een andere flag zetten
         --LOOP TELLER BETWEEN 1 AND  6
         While teller <= 5 LOOP
    SELECT titel INTO TestVeld FROM ticket WHERE
    RE ticketid = Tussen_ticketid;
    --Veld_dat_ingevuld_moet_zijn INTO  TestVeld FROM
    OM ticket WHERE ticketid = Tussen_ticketid;
              -- dit zou het datumveld moeten zijn
              IF TestVeld is NOT NULL THEN
                   -- dan is dat record ok voor gebruik
    -- wel nog nakijken welke veld dat moet zijn, moet
    oet altijd ingevuld zijn
                   -- waarde doet er niet toe
    --Query_to_use := Query_to_use || ' UNION SELECT
    ECT ticketid, applicatiecd, '||
    --' categorieid, titel, klantprioriteitid,
    id, interneprioriteitid, gebruikerid, statusid,'||
                   --' versieid FROM ticket WHERE ticketid = ';
                   IF Teller = 1 THEN
    Ticketid_place1 :=
    Tussen_ticketid;
    Query_to_use :=
    Query_to_use || 'Ticketid_place1';
                   ELSIF Teller = 2 THEN
    Ticketid_place2 :=
    Tussen_ticketid;
    Query_to_use :=
    'UNION'||Query_to_use || 'Ticketid_place2';
                   ELSIF Teller = 3 THEN
    Ticketid_place3 :=
    Tussen_ticketid;
    Query_to_use :=
    'UNION'||Query_to_use || 'Ticketid_place3';
                   ELSIF Teller = 4 THEN
    Ticketid_place4 :=
    Tussen_ticketid;
    Query_to_use :='UNION'||
    Query_to_use || 'Ticketid_place4';
                   ELSIF Teller = 5 THEN
    Ticketid_place5 :=
    Tussen_ticketid;
    Query_to_use :='UNION'||
    Query_to_use || 'Ticketid_place5';
                   ELSIF Teller = 6 THEN
                        Teller := Teller + 1;
                   END IF;
                   Teller := Teller + 1;
                   Tussen_ticketid := Tussen_ticketid - 1;
              ELSIF
                   Tussen_ticketid := Tussen_ticketid - 1;
              END IF;
         END LOOP;
         -- dbms_output.Put_line(Query_to_use);
         RETURN Query_to_use;
    END;WHat are you trying to achive by this code? Please explain this bolded script part. I didn't see any function is using here. But, you are returning one value to where? Or may be i overlooked it. Please explain it.
    Regards.
    Satyaki De.

  • Simple Query Question - How do I return the Last 3 records of a Table?

    Question.
    For example, I have a table that has 50 records.
    How do I, specify in SQL to only return the last 3 records of the table.
    Select a.* from table a where ????

    I was just trying to show an example to a friend on
    how something like this would work and if it was even possible. But it won't work. Here's a simple example:
    SQL> create table emp
      2  (id)
      3  as
      4  select object_id
      5  from   all_objects
      6  order  by object_id;
    Table created.
    SQL> select *
      2  from  (select rownum rn
      3               ,b.*
      4         from   emp b)
      5  where  rn > ( select (max(rownum) - 3)
      6                from    emp)
      7  ;
            RN         ID
         40830      55891
         40831      55892
         40832      55893So far, so good. These are the "last 3" rows inserted. Now delete a bunch of rows and insert 3 new ones:
    SQL> delete emp where id < 40000;
    33423 rows deleted.
    SQL> commit;
    Commit complete.
    SQL> insert into emp values (60000);
    1 row created.
    SQL> insert into emp values (60001);
    1 row created.
    SQL> insert into emp values (60002);
    1 row created.
    SQL> commit;
    Commit complete.
    SQL> select *
      2  from  (select rownum rn
      3               ,b.*
      4         from   emp b)
      5  where  rn > ( select (max(rownum) - 3)
      6                from    emp)
      7  ;
            RN         ID
          7410      55891
          7411      55892
          7412      55893Here's the problem. Even though the "last 3 rows" are 60000 - 60002, I still get the same ones as the first query.

  • Different ways to get the last 5 records ordered by date

    I have a query no that returns the tickets ordered by moddt, modification date,
    I was thinking of adding a select on top, to get the last 5 records of that list the select already generates. An other way was to use that select to create a view,
    and get the 5 last records that way. I also though of a possibly impossible cursor with a sequence, but hmm well I consider that not a good solution.
    So I'm trying to find a way, using a select, the topmost select which is not completed yet, to get the last 5 records. Maybe I should just try the rownumber thing again or something likewise.
    Select * from(
    select * from(
    Select ticketid, appliecatiecd, categorieid, substr(titel,&,200)||' ...' "titel", klantproriteitid, interneprioriteitid,
    (select g.voornaam||' '||g.naam
    from gebruiker g
    Where g.gebruikerid = t.gebruikerid
    And t.applicatiecd = NVL(:P0_applicatiecd, :F101_applicatiecd))"aangemaakt door",
    (select s.statusdefoms "status"
    From status s
    Where s.statusid = t.statusid
    And t.applicatiecd = NVL(:P0_applicatiecd, :F101_applicatiecd)) "status",
    Versieid,
    Moddt,
    Row_number() over (order by ticketid desc) rn
    From ticket t
    Where applicatiecd = NVL(:P0_applicatiecd, :F101_applicatiecd) )
    Order by moddt)
    Where --

    Hi Floris,
    You can also use RANK: http://www.dba-oracle.com/oracle_news/oracle_faq/faq_beg_sql_top_n_rows.htm
    Regards Pete

  • Get more info about the last errors in Oracle

    Hi all,
    There is a log in a live system where it is possible to see every minute the following error:
    Sweep Incident[48073]: failed, err=[1858]
    I know that error can happen mainly when:
    1. Trying to insert caracter field in a numeric column
    2. Using in the wrong way the function to_date()
    I need more information about that error, what can be causing the error in the system and why. Is it possible to see more information about the last errors in Oracle? For example, if a query produces an error... is it possible to see in Oracle the error and the query that caused the error?
    Hope you can help me.
    Thanks in advance.

    Thanks Niall.
    I'm not sure if I got you...
    What I found is that MMON makes snapshots of the database 'health' and stores this information in the AWR. So, it seems like in the database there could be a numeric column that is storing character fields, and when MMON works, it finds that error... is that right?
    I found the following information:
    SQL> select substr(s.username,1,18) username,
    2 substr(s.program,1,22) program,
    3 decode(s.command,
    4 0,'No Command',
    5 1,'Create Table',
    6 2,'Insert',
    7 3,'Select',
    8 6,'Update',
    9 7,'Delete',
    10 9,'Create Index',
    11 15,'Alter Table',
    12 21,'Create View',
    13 23,'Validate Index',
    14 35,'Alter Database',
    15 39,'Create Tablespace',
    16 41,'Drop Tablespace',
    17 40,'Alter Tablespace',
    18 53,'Drop User',
    19 62,'Analyze Table',
    20 63,'Analyze Index',
    21 s.command||': Other') command
    22 from
    23 v$session s,
    24 v$process p,
    25 v$transaction t,
    26 v$rollstat r,
    27 v$rollname n
    28 where s.paddr = p.addr
    29 and s.taddr = t.addr (+)
    30 and t.xidusn = r.usn (+)
    31 and r.usn = n.usn (+)
    32 order by 1;
    USERNAME PROGRAM COMMAND
    oracle@airvs1b (MMON) No Command
    SQL> select addr, pid, spid, username, serial#, program,traceid, background, latchwait, latchspin from v$process where program='oracle@airvs1b (MMON)';
    ADDR PID SPID USERNAME SERIAL# PROGRAM
    000000044A4E48A8 24 15372 oracle 1 oracle@airvs1b (MMON)
    TRACEID B LATCHWAIT LATCHSPIN
    ---------------- ---------- ------------------------ --------------- 1
    SQL> select
    2 substr(a.spid,1,9) pid,
    3 substr(b.sid,1,5) sid,
    4 substr(b.serial#,1,5) ser#,
    5 substr(b.machine,1,6) box,
    6 substr(b.username,1,10) username,
    7 b.server,
    8 substr(b.osuser,1,8) os_user,
    9 substr(b.program,1,40) program
    10 from v$session b, v$process a
    11 where
    12 b.paddr = a.addr
    13 and a.spid=15372
    14 order by spid;
    PID SID SER# BOX USERNAME SERVER OS_USER PROGRAM
    15372 1082 1 airvs1 DEDICATED oracle oracle@airvs1b (MMON)
    Is there any way I can see what MMON is doing and when is failing?
    Thank you very much.
    Edited by: user11281526 on 19-jun-2009 5:18

  • Making an average of the last 100 values?

    Hi everyone,
    I am acquiring a signal every 1000mS with Labview 7.1. I need to make an average of the last 100 values every 1000mS. I know how to do this with shift registers but it would be a bit long to do it this way...There must be a better way
    Would anybody have an example of an array that takes into consideration the new value that has just been acquired, so that I can make an average of the array?
    Thank you very much for your help,
    Toto

    Hi Toto,
    Here is the first thing I thought of.  Initialize an array of 1000 elements, and replace an element each iteration of the loop.  Use the Quotient and Remainder function along with the iteration count of the loop to replace the oldest element in the array.  Add the array and divide by 1000 in each iteration to get the current average.  I've attached the VI (saved in LabVIEW 7.1), along with a screenshot for anyone who wants to see it but doesn't have LabVIEW 7.1 or later.
    Good luck,
    -D
    Message Edited by Darren on 02-05-2006 07:40 PM
    Darren Nattinger, CLA
    LabVIEW Artisan and Nugget Penman
    Attachments:
    Running_average.vi ‏11 KB
    Running_average.jpg ‏32 KB

  • Select the last saved records in a table

    I all
    I have this struct in a table
    create table INT_OBJ
    IDOBJ NUMBER(15) not null,
    IDERP NUMBER(15),
    IDE NUMBER(15),
    CPO VARCHAR2(20),
    VLR VARCHAR2(2500),
    VLRC VARCHAR2(2500)
    How to Select the last saved records in a table. I think usea a temp table for put the last row read and begin to read in the next row.
    The table is reading each four hours.

    Theoretically it can be done with ORA_ROWSCN and enabled ROWDEPENDENCIES, but there are so many nuances, so only adding column for ordering is right.
    Regards,
    Sayan Malakshinov

  • How to get the last inserted record from a table ?

    :-) Hiee E'body
    I work on Oracle 8i and need to get the last
    record inserted in a table.
    I have tried using rownum and rowid pseudo-columns
    but that doesn't work.
    Can you please help me out ?
    :-) Have a nice time
    Vivek Kapoor.
    IT, Atul Ltd.,
    India.

    I'm not sure about 8i features.
    I assume here that you don't have 'Date-Time' stamp columns on the table which is the easiest way to determine the last inserted row in the table.
    If not try the following :-
    select address, piece, SQL_TEXT
    from V$SQLTEXT
    where upper(sql_text) like '%INSERT INTO TABLE_NAME%'
    Substiute the TABLE_NAME with the name of the actual table.
    Have fun.
    Regards,
    Shailender
    :-) Hiee E'body
    I work on Oracle 8i and need to get the last
    record inserted in a table.
    I have tried using rownum and rowid pseudo-columns
    but that doesn't work.
    Can you please help me out ?
    :-) Have a nice time
    Vivek Kapoor.
    IT, Atul Ltd.,
    India.

  • Averaging over the last hour and last eight hours.

    This is fairly simple but I'm not sure what a "good" approach is. Basically I need to track how many times a user has performed an action over the last hour and last eight hours. I'll receive a notification of some sort when they perform this action and could get the current time, but I'm not sure what a fast way of determining how many times this has occurred in a given time period is.
    I was thinking perhaps an array with the time of each in milliseconds and just find the first index that was < 8 hours or < 1 hour ago and then subtract the index from the current size. I think that would be problematic though. To keep the array from continuously growing I'd have to shift everything over to the left which means an expensive arraycopy. Perhaps if I only did the resizing when there were > 20 or elements I no longer care about or something would help, but then I'd have to iterate over 20 elements I don't care about everytime it's calculated, which is once a second.
    Any algorithms that will solve this?

    Here is a method with a granularity of a minute (i.e.
    it only updates the average value every minute - you
    can change it to give whatever granularity you want)
    Keep an array with 60 elements in it. The array
    counts the number of times that the user performed
    the action each minute.
    The array in indexed modulo real time, and you make
    entries based on actual time of day. So when a user
    performs an action at 8:38:45 you increment slot 38.
    Each slot counts the number of actions that took
    place in that particular minute. When the next minute
    rolls around, you move to the next slot, set the
    value to zero (thus throwing out the events that
    happened over an hour ago, and prepare to count the
    new events)
    The sum of the entire array is of course the total
    number of events that have taken place in the last
    hour.
    You do not need to actually run through the array and
    total the events every time you want to calculate the
    average. You can use the fact that you increase the
    total by one every time you get a new event and you
    decrease the total by X everytime you zero out a slot
    that had X for its event count.
    So you can just keep a single value, Total, along
    with your array that goes up by one on every event
    and then drops back a little every minute, when you
    throw out the hour old events.That is probably a good solution to the question I posed, but I realize now I was not thorough or accurate enough in describing the context and requirements. I don't think that will work without a lot of unnecessary memory, but maybe I'm wrong.
    The user action is actually the successful completion of entering a form, a bill to be more precise. I expect this to happen 100-300 times an hour to give an idea of the frequency. Given a period of time, if they've been at it for that period of time or longer I need to find the number of bills completed in that most recent period of time. Otherwise, I need to use what is available to predict what they will reach in that period of time. In other words, if the time period is an hour I need to figure out how many bills were completed in the last hour, but if they've been going for only five minutes I need to predict what they will have completed in an hour including those last five minutes. Then I need to do the same thing for seven hours, using the last seven hours or less of data.
    I guess I'd just have to use a granularity of a minute or less and calculate how many bills over how many minutes and make a prediction on that? I suppose I was hoping for something more precise, but now that I think about it that will probably suffice.
    How would you implement it though? Create a "minute" array of size 60 initially, then when reaching the end of that array adding the total for that array to an "hourly" array (keeps track of bills in that hour) and then start over? I guess then you'd just have to add each from the hourly array to the current total and calculate based upon that. At any given time I'd have the number of bills processed in the last x hours and y minutes, which is enough to calculate how much can be completed at that rate in a given hour or seven hour day.
    I'll try this tomorrow when I get to work, thank you very much I was needlessly complicating it with timestamps. In fact, this inadvertently (or perhaps purposefully?) solves an issue with not calculating time when a user is at lunch or on break. At least I think it does.

  • Getting information about the last opened document?

    Hi there!
    I've got a question about the reader and it's opened documents: Is there any possibility to get any information about a document, that was already opened by the Adobe reader?
    Example: I open xyz.pdf, and after closing the reader, i want to check what the last page was, the user looked at. Or the time, when this document was closed.
    thanks
    Daniel

    Try something like this:
    Font font = UIManager.getFont("Button.font");hope this helps!

  • On down loading a file the download windo appears but does not liost any files. The same happens under Thuinderbird. Has appied for about the last 2 or 3 weeks. I have the latest upgrades as of 8/18.

    When I down load a file the down loads window opens but no files are listed there. (This also happens under Thunderbird). I have updated both T'bird and Firefox in the last couple of weeks. The download window was working ok , say, about 3 weeks ago. About then I cleared an existing lsit of files. Since then, nothing is shown even tho I have downloaded a few files.

    alternitive soltuion:
                    I have finally figured this out.
                    The VMM service runs under the Local System account, I changed it to use the domain account I logged in with. I also had to change the SQL service account to use the same domain account the VMM service runs under.
    Prior to performing the above actions, I modified the certificate in MMC > Certificates to not use the Smart Card option from the users profile. Shown below. To make this modification. Follow these steps.
    1.       Open MMC
    2.       Open > File > Add/Remove Snap-ins
    3.       Select Certificates, and click Add (ensure Current – User is selected)
    4.       Click OK
    5.       Navigate to > Personal > Certificates
    6.       Double click on the user Cert
    7.       Select the Details Tab, > click the Edit Properties
    8.       Select “Enable only the following purposes
    9.       Uncheck Smart Card Logon
    After the above actions was performed, I then modified the service account the VMM and SQL service was using to use a domain account, and things started working.
    Richard Dixon MSFT
    Sr Systems Engineer

  • Query to get the last added record in a table for a particular id

    T
    Hi,
    I have 2 tables A, B
    Table A has id,name
    Table B had parentid(foreignkey referring to ID in above table), record_type,created_timestamp
    I want to get the last added record_type from Table B for all the ids present in Table A.

    Please post DDL, so that people do not have to guess what the keys, constraints, Declarative Referential Integrity, data types, etc. in your schema are. Learn how to follow ISO-11179 data element naming conventions and formatting rules. I know this is
    a skeleton, but could you at least try to do good programming? Temporal data should use ISO-8601 formats. Code should be in Standard SQL as much as possible and not local dialect. 
    This is minimal polite behavior on SQL forums. And sample data also helps. 
    I have 2 tables: Alphas, Betas
    CREATE TABLE Alphas
    (alpha_id CHAR(10) NOT NULL PRIMARY KEY,
     alpha_name VARCHAR(25) NOT NULL);
    Why was that DDL so hard you could not write it? But your narrative about the second table does not tell us if it has a key. I will guess that it is also alpha_id, but thanks to your rudeness, that is all we can do. 
    CREATE TABLE Beta 
    (alpha_id CHAR(10) NOT NULL PRIMARY KEY
       REFERENCES Alphas (alpha_id),
     record_type CHAR(2) NOT NULL,
     creation_timestamp DATETIME2(0) DEFAULT CURRENT_TIMESTAMP
          NOT NULL,
    >> I want to get the last added record_type from Table Beta for all the ids present in Table A.<<
    Think about this. Since Beta.alpha_id is a FOREIGN KEY to Alphas, all of its rows will have a match to Alpha. The SQL engine does this for you! 
    SELECT *
    FROM (SELECT alpha_id, record_type, creation_date,
                  MAX(creation_date) OVER () AS creation_date_max
            FROM Betas)
    WHERE creation_date = creation_date_max;
    --CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
    in Sets / Trees and Hierarchies in SQL

  • I want to plot the average of the last 10 points

    My program is running at 10 Hz (I have 100ms wait in my main FOR loop), but I want to plot and save data at 1Hz. But since I'm already running 10x faster than my desired plot rate I'd like to average the 10 points which are collected between plots. I'm sure there is a simple straight forward way to do this but I haven't figured it out yet.
    Any help would be appreciated.
    Ron

    rsi77 wrote:
    OK, that looks helpful, but I have one other requirement: I want the program to be able to respond to my input (number source) at the higher frequency. As I understand your diagram my number source would be stuck in the loop and the numbers would only be available to the whole program at the slower rate--am I understanding this correctly? So I want to loop through my program 10 times and respond to those 10 numbers, but then take the average of those last ten numbers and plot/write them to chart/file.
    Thanks.
    You would put the logic to handle the numbers sample by sample inside the inner loop if that were the case. If they need to save data between iterations, use shift registers or feedback nodes. Look at the example altenbach posted as well. Either of these should help get your thinking in the right place in order to tweek out your own solution. Altenbach's solution might be the more efficient of the two, since it only involves 1 loop.

Maybe you are looking for