473,387 Members | 1,621 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,387 software developers and data experts.

Checking a condition to be true over 9 consecutive months

jr
A perplexing one this.

I Am trying to design a query or series of queries which will firstly
identify a condition.
If column A value is less than column B value make column C value =1 ,
else 0.
This is easy enough

Then I want to identify all rows where column C = 1 ,

no problem so far

However I then want to find in resultant dataset if the rows have
consecutive monthly values.

ie row 2 column D - row 1 column D = between 28 and 31. ?????
If there is a break in the sequence before 9 is met ie row 8 column d - row
7 column d - Then we start again from 1 on the next comparison.

Can it be done with Access 2002 - Or will I be writing a good old VB module
Nov 13 '05 #1
3 2352
If the baby was born in the time frame predicted by your doctor you can say
first, the mother is not a virgin and, second, the mother was pregnant over
nine consecutive months.

--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
re******@pcdatasheet.com
www.pcdatasheet.com
"jr" <jr************@virgin.net> wrote in message
news:Jl*****************@newsfe7-win.ntli.net...
A perplexing one this.

I Am trying to design a query or series of queries which will firstly
identify a condition.
If column A value is less than column B value make column C value =1 ,
else 0.
This is easy enough

Then I want to identify all rows where column C = 1 ,

no problem so far

However I then want to find in resultant dataset if the rows have
consecutive monthly values.

ie row 2 column D - row 1 column D = between 28 and 31. ?????
If there is a break in the sequence before 9 is met ie row 8 column d - row 7 column d - Then we start again from 1 on the next comparison.

Can it be done with Access 2002 - Or will I be writing a good old VB module

Nov 13 '05 #2
On Sun, 24 Jul 2005 15:21:13 GMT, "jr" <jr************@virgin.net> wrote:
A perplexing one this.

I Am trying to design a query or series of queries which will firstly
identify a condition.
If column A value is less than column B value make column C value =1 ,
else 0.
This is easy enough

Then I want to identify all rows where column C = 1 ,

no problem so far

However I then want to find in resultant dataset if the rows have
consecutive monthly values.

ie row 2 column D - row 1 column D = between 28 and 31. ?????
If there is a break in the sequence before 9 is met ie row 8 column d - row
7 column d - Then we start again from 1 on the next comparison.

Can it be done with Access 2002 - Or will I be writing a good old VB module

Hi
Say you have a query called "runstrue" with just one field "monthnumber", which is the months
for which some condition is true. (I assume months are a single increasing set of numbers).

Define a table "mynumbers" with a single field "mynum", with values 1, 2, 3 etc upto at least
9 in your case. (Make it the primary key).

Then this query will show you all runs (sequences) of 9 months for which the condtion is true:

SELECT mynumbers_1.mynum AS runlength, mynumbers.mynum AS startmonth
FROM mynumbers, mynumbers AS mynumbers_1, runstrue
WHERE (((runstrue.monthnumber) Between [mynumbers].[mynum] And [mynumbers].[mynum]+[mynumbers_1].[mynum]-1))
GROUP BY mynumbers_1.mynum, mynumbers.mynum
HAVING (((mynumbers_1.mynum)>=9) AND ((Count(runstrue.monthnumber))=[mynumbers_1].[mynum]))
ORDER BY mynumbers_1.mynum;

It may not run very quickly if tables are big!

Most "SQL" methods for detecting runs in data use proprietary features of different vendors, eg mdiff for Teradata.

David

Nov 13 '05 #3
Donnie, are you impersonating Steve now; or, Steve, have you absorbed too
much of Donnie's blather?

"PC Datasheet" <no****@nospam.spam> wrote in message
news:HM*******************@newsread1.news.atl.eart hlink.net...
If the baby was born in the time frame predicted by your doctor you can
say
first, the mother is not a virgin and, second, the mother was pregnant
over
nine consecutive months.

--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
re******@pcdatasheet.com
www.pcdatasheet.com
"jr" <jr************@virgin.net> wrote in message
news:Jl*****************@newsfe7-win.ntli.net...
A perplexing one this.

I Am trying to design a query or series of queries which will firstly
identify a condition.
If column A value is less than column B value make column C value =1 ,
else 0.
This is easy enough

Then I want to identify all rows where column C = 1 ,

no problem so far

However I then want to find in resultant dataset if the rows have
consecutive monthly values.

ie row 2 column D - row 1 column D = between 28 and 31. ?????
If there is a break in the sequence before 9 is met ie row 8 column d -

row
7 column d - Then we start again from 1 on the next comparison.

Can it be done with Access 2002 - Or will I be writing a good old VB

module


Nov 13 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

18
by: Domestos | last post by:
Hi all, How do I check in a mySQL table called 'Users' on column user_name when registering a new user_name to make sure the new 'user_name' does not already exist in that column? TIA
6
by: Stephen | last post by:
Im trying to carry work out an else if clause in the below method but i'm having a lot of difficulty getting the correct code which allows me to check and see if an arraylist items has text in it...
3
by: Jack | last post by:
Hi, I have a form when loaded, retrieves record from an access table. Among other fields there is a check box called FinalUpdate. This is tied to a field in Access of type Yes/No. The form...
5
by: Andy G | last post by:
I'm getting this error...Operator is not valid for type 'DBNull' and string "". What is happening is that I'm calling a stored procedure to use the email address to recover a forgotten username. ...
8
by: Brendan | last post by:
There must be an easy way to do this: For classes that contain very simple data tables, I like to do something like this: class Things(Object): def __init__(self, x, y, z): #assert that x,...
16
by: Claudio Grondi | last post by:
Sometimes it is known in advance, that the time spent in a loop will be in order of minutes or even hours, so it makes sense to optimize each element in the loop to make it run faster. One of...
27
by: RobG | last post by:
I was investigating a function to determine whether daylight saving was being observed on a particular date (given the platform's regional settings) and came across a suggestion at merlyn.com to...
7
by: Tarscher | last post by:
Hi all, I have classes: Unit, Transporter, Bus and Car Transporter inherits from Unit and Bus and Car inherit from Transporter. I want to be able to do Bus bus = new Bus() if (bus is...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...

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.