473,698 Members | 2,225 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2367
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******@pcdata sheet.com
www.pcdatasheet.com
"jr" <jr************ @virgin.net> wrote in message
news:Jl******** *********@newsf e7-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 "monthnumbe r", 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.myn um AS runlength, mynumbers.mynum AS startmonth
FROM mynumbers, mynumbers AS mynumbers_1, runstrue
WHERE (((runstrue.mon thnumber) Between [mynumbers].[mynum] And [mynumbers].[mynum]+[mynumbers_1].[mynum]-1))
GROUP BY mynumbers_1.myn um, mynumbers.mynum
HAVING (((mynumbers_1. mynum)>=9) AND ((Count(runstru e.monthnumber)) =[mynumbers_1].[mynum]))
ORDER BY mynumbers_1.myn um;

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******** ***********@new sread1.news.atl .earthlink.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******@pcdata sheet.com
www.pcdatasheet.com
"jr" <jr************ @virgin.net> wrote in message
news:Jl******** *********@newsf e7-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
1764
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
1829
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 containing Address not supplied. Im trying to do something below but its not working properly. Can someone help me do this please. the code i use is below. private void checkArrayList() { ArrayList alSearchaddress; alSearchaddress =...
3
2339
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 retieves the values perfectly. This form is being used to update the record in the table via a successconfirmation.asp. Now, when the checkbox is loaded as checked, then unchecking the checkbox reflects the change in query result in...
5
1788
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. If the email does not exist then I get the above error. After I execute the stored procedure I try and apparenty this is not catching the error. Should I use a Try...Catch? What is the correct way to check for nulls in ASP.NET? If Not...
8
1877
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, y, and z have the same length But I can't figure out a _simple_ way to check the arguments have the
16
3523
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 instructions which can sure be optimized away is the check for the break condition, at least within the time where it is known that the loop will not reach it. Any idea how to write such a loop? e.g.
27
6866
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 test the time zone offset on a variety of dates to see if it changes. Based on that, I developed the following checkDST() function which, as far as I can tell, should be sufficient. It checks either the date passed to it or the current date with...
7
2948
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 Transporter)
0
8603
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9157
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9026
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7723
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6518
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4619
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3045
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2328
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2001
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.