473,395 Members | 1,978 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Query for event and outcome.

I have a problem that I need to solve in MS Access 2000. I know how to do this in Excel. However this needs to be in Access due to a customer’s requirement.

I have a list of events and what the out come was on a particular date. To give you some idea, the event is basically number given to a day and the outcome is all possible things that “could happen” and that did happen (so not all 160 possible Outcomes are used all the time).

So it is quite possible to have:

Event 1 (This could be “Monday”)
Outcome 12 (This could be “Rain”)


There for as you collect your data over time the “Outcome Diff” would = 12 (for the first time) this is because it happened 12 day into the checks. Then the counter sets to zero, event 2, out come 12 is then 1 as it happened on out come 2, but on Event 13 as it did not rain for a while, is then 11.

The problem comes when I try to create a report to automatically calculate the “Outcome Diff” this in a Query as the “counter” that should have been added at the time this was created was not done at the time. I also do not mind if this has to involve creating to a table, as long as I get the “outcome diff” calculated in MS Access, I do not mind how this is done. I also cannot use date diff as event mean more than just an index for the day.

Event, Outcome, Date, Outcome Diff
1, 12, 14-Feb-95, 1
2, 12, 19-Apr-95, 1
13, 12, 07-Jun-95, 11
18, 12, 08-Jul-95, 5
2, 35, 12-Jul-95, 2
4, 35, 15-Aug-95, 2
7, 35, 12-Sep-95, 3
20, 73, 16-Apr-96, 20
60, 102, 31-Oct-96, 60
16, 105, 16-Nov-96, 16

*This is just a representation with test data.

Just for further clarification, the reason I need this is because, they need to know the difference in days as opposed to an average (an average on 12 outcome’s would 4.5) when really, they need to know that 2/18 days it rained without any day gaps.
Jan 14 '08 #1
3 1587
Rabbit
12,516 Expert Mod 8TB
You'll have to use some subqueries to return what you need.
Expand|Select|Wrap|Line Numbers
  1. SELECT x.Event, x.Outcome,iif(x.Outcome = (SELECT TOP 1 Outcome FROM Table1 WHERE EDate < x.EDate ORDER BY EDate Desc), x.Event-nz((SELECT TOP 1 Event FROM Table1 WHERE EDate  < x.EDate ORDER BY EDate Desc),0), x.Event) AS OutcomeDiff
  2. FROM Table1 AS x;
  3.  
Jan 15 '08 #2
Thanks ever so much :-)
Jan 16 '08 #3
Rabbit
12,516 Expert Mod 8TB
Not a problem, good luck.
Jan 16 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Együd Csaba | last post by:
Hi All, how can I improve the query performance in the following situation: I have a big (4.5+ million rows) table. One query takes approx. 9 sec to finish resulting ~10000 rows. But if I run...
0
by: Scott Morford | last post by:
This is a followup to a question I posed last summer. http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=utf-8&selm=3f451dd4%240%241095%247f8943f3%40newsreader.visi.com I'm developing a weed...
5
by: Q. John Chen | last post by:
On a webForm, I have a DropDownList with AutoPostBack=true and I also have couple textbox with AutoPostBack=false. I am expect that the DropDownList's SelectedIndexChanged event being handled...
5
by: Bob Bridges | last post by:
Start with two tables, parent records in one and child records in the other, a one-to-many relationship. Create a select statement joining the two. Display the query in datasheet mode. When I...
5
by: Photo | last post by:
Hello everyone this is my first post so as you could guess I need some help. Here is my situation, I have 2 tables, one caled personnel and one called DET_Dates, DET_Dates is linked to Personnel on...
2
theaybaras
by: theaybaras | last post by:
Hi all, I have a table and a subtable . CAssessments is a combobox that looks up a table called AssessList has 2 columns, an autonumber PK and a string for the title of the Assessment. ...
10
by: Ugo | last post by:
Hi guys, until now I make so: <div id="my_div"><!-- content --></div> MyClass.prototype.doSomething = function( ) {}; MyClass.prototype.assignFun = function( )
11
by: hedges98 | last post by:
The thread title probably isn't very clear but I can't think how to word my problem properly. Here goes: I have a form that has textboxes for users to enter information for first appointments and...
7
by: SteveGod | last post by:
Hi, I'm trying to create a report that will produce automated sets of Committee Minutes for School Appeals, where there are a set range of different outcomes. The field involved are all from...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.