Results 1 to 6 of 6
  1. #1
    wilkesgra is offline Novice
    Windows 2K Access 2000
    Join Date
    Sep 2010
    Posts
    3

    cumulative rainfall query

    Hello,



    I have a query building a table named (idpap rus running rain), with columns id, yrdy, and ru_totalrain, please see the attachment.

    Can someone suggest an faster query to calculate cumulative rainfall in 1, 2, 3, and 7 days in advance (or records in advance) of each yrdy, including the value on yrdy?

    I've been using a select query with dlookups like the following and it takes forever...

    RU_TOTALRAIN1D: DLookUp("[RU_TOTALRAIN]","idpap rus running rain","[ID]=" & [ID]-1)+[RU_TOTALRAIN]

    Especially for the 7 day cumulative lookup...

    Suggestions would be appreciated!

  2. #2
    weekend00 is offline I may not be right
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    1,295
    This query calculates 7 day advance (total 8 days), if you want 1,2,3,4 days, just change 7 to 1,2,3,4:

    SELECT Sum(A.U_TOTALRAIN) AS SumOfU_TOTALRAIN, B.YRDY
    FROM [idpap rus running rain] AS A, [idpap rus running rain] AS B
    WHERE (((A.YRDY)>=[B].[YRDY] And (A.YRDY)<=[B].[YRDY]+7))
    GROUP BY B.YRDY;

  3. #3
    wilkesgra is offline Novice
    Windows 2K Access 2000
    Join Date
    Sep 2010
    Posts
    3
    Thanks for the reply. Sorry, to clarify, I meant values previous to the record, not after the record. To change, can I use -7???

  4. #4
    wilkesgra is offline Novice
    Windows 2K Access 2000
    Join Date
    Sep 2010
    Posts
    3
    Oh, and not summing if there is lack of data in the moving window would be incredible.

  5. #5
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    wilk,

    make sure to check your cross postings: http://www.access-programmers.co.uk/...d.php?t=199543

    someone else provided you with a link that might just solve the problem right off...

    if it doesn't though, that's fine, but cross posting is so frowned upon. There would be a lot of people that would appreciate it if you didn't do it. thanks!

  6. #6
    weekend00 is offline I may not be right
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    1,295
    if you want to try again, change to following to calculate days previous:

    WHERE (((A.YRDY)<=[B].[YRDY] And (A.YRDY)>=[B].[YRDY]-7))

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Cumulative sum (columns)
    By ravens in forum Queries
    Replies: 1
    Last Post: 03-02-2010, 08:14 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums