Specific Date range based off of other data

Hallel86

Registered User.
Local time
Today, 13:37
Joined
Jun 14, 2013
Messages
14
Novice access user here! I am looking for assistance with a query.

Let's say I have multiple buildings that I own. Each building earns a monetary amount each day. Some days they earn $0, some days they earn $1,000. This is all kept track in a data base in which someone manually enters the information each day.
The three fields are:
Building
Date
Profit

I have narrowed a query down to one building, and I am interested in two things. How do I write a query that shows a 30 day peak (the most profitable 30 days). In other words. I want to see the following
Building: GNB Tower Date: 02/14/13 - 03/15/13 Profit: $25,162

The next thing I am interested in is a 7 day peak from within these 30 days. This shouldn't be too difficult if I can figure out how to query these 30 days, I can query 7 days out of those 30 days. So this bigger mind stumper is the first one.

out of a date range of months and months (Let's say 10/12/13 - 6-14-13)

Once I figure this part out, I am sure I can figure out how to compile all buildings into one large report with their 7 day peak and 30 day peak. There is more to this report that seems fairly simple, but this particular issue is getting the best of me. I am just looking for some helpful and friendly advice. Whether someone would like to link me somewhere, or show me a book I can purchase to teach me this stuff (which I would prefer both), does not matter to me. Thank you very much :)
 
First, you shouldn't have a field called 'Date', that's a reserved word in Access and will give you trouble when writing code (which you will need to do for this issue). I suggest prefixing it with what that date is for (i.e. ProfitDate).

Your issue is essentially a complex running total (Search this forum for 'Running Total' and it will help). You need to create a query based on your profit table that calculates the past 30 day total for every record, based on that record's date. Once you have that query built, you create an aggregate query based on it that finds out the largest 30 day total for every building.
 

Users who are viewing this thread

Back
Top Bottom