473,842 Members | 1,588 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Query which groups months between startdate and enddate

8 New Member
Hi fellows: I am at a complete lost as to how to construct a query or report to answer this question. Any help is greatly appreciated. The question I need to answer is this:

Identify the SchID and month for each SchID/Month combo for which there is not at least one associated AttendanceDate between that SchID's StartDate and EndDate.

Table structure:

tblSchedules
------------------
SchID
StartDate
EndDate

tblAttendance
--------------------
AttendanceID
SchID
AttendanceDate
AttendanceStatu s
Nov 16 '07 #1
2 1577
QVeen72
1,445 Recognized Expert Top Contributor
Hi fellows: I am at a complete lost as to how to construct a query or report to answer this question. Any help is greatly appreciated. The question I need to answer is this:

Identify the SchID and month for each SchID/Month combo for which there is not at least one associated AttendanceDate between that SchID's StartDate and EndDate.

Table structure:

tblSchedules
------------------
SchID
StartDate
EndDate

tblAttendance
--------------------
AttendanceID
SchID
AttendanceDate
AttendanceStatu s
Hi,

what does this mean :" for which there is not at least one associated"..?

Post some Test data and required output, as your question is very confusing...

Regards
Veena
Nov 16 '07 #2
HoganGroup
8 New Member
Yes, it is very, very confusing. By associated I mean the primary key in tblSchedules associated with its foreign key in tblAttendance. Here's some sample data:

INPUT
tblSchedules
-------------------
SchID, StartDate, EndDate
10, 1/1/07, 2/28/07
20, 1/1/07, 3/31/07
30, 1/1/07, 3/31/07

tblAttendance
--------------------
AttID, SchID, AttDate, AttStatus
444, 10, 1/1/07, "Present"
445, 10, 2/7/07, "Present"
446, 20, 1/1/07, "Present"
447, 20, 1/5/07, "Present"
448, 30, 2/1/07, "Present"
449, 30, 3/6/07, "Present"

OUTPUT
SchID:20, Month:2/07
SchID:20, Month:3/07
SchID:30, Month:1/07

LOGIC
SchID:10 has at least one record in tblAttendance for every month it's suppose to (the months between it's startdate and enddate, 1/07 and 2/07) so it is not output
SchID:20 should have at least one day of attendance in 2/07 and 3/07 but does not, so those months are output
SchID:30 should have at least one day of attendance in 3/07 but does not, so that month is output
Nov 16 '07 #3

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

Similar topics

3
1634
by: Lea | last post by:
Having a problem with a query within a table for appointment schedules. In this table tblMeetingInfo are two fields, StartDate and EndDate. The date information is entered into each of these fields like: 1/12/2005 (This could represent data entered into either field). Most appointments are one day in duration. In this example, StartDate would be equal to Enddate: 1/12/2005 to 1/12/2005 (StartDate to EndDate).
6
17935
by: Tony Miller | last post by:
All I have an aggregate query using the function Month & Year on a datereceived field ie: TheYear: Year() TheMonth: Month() These are the group by fields to give me a Count on another field by year & month When I try to place a date filter 'Between x And y ' on an expression field
11
3157
by: Andy_Khosravi | last post by:
My problem: I'm having trouble with a query taking much too long to run; a query without any criteria evaluating only 650 records takes over 300 seconds to run (over the network. On local drive takes 120 seconds). The Setup: I'm running Access 97 non-developer edition. I have exactly zero other tools to use and no way to change that =(. My database is compiled and resides on a network drive. The database has not been split into a...
2
5609
by: paulmitchell507 | last post by:
I think I am attempting a simple procedure but I just can't figure out the correct syntax. My asp (classic) page runs a SELECT query to obtain dates and ID's from 2 tables uSQL = "SELECT cal_date, holiday_ID from Calendar, holiday_tbl WHERE (((calendar.cal_Date) Between . And .)) And Email_sent=0 AND Staff_ID=" & Staff_ID This works fine.
0
9876
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, weíll explore What is ONU, What Is Router, ONU & Routerís main usage, and What is the difference between ONU and Router. Letís take a closer look ! Part I. Meaning of...
0
9717
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
10950
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
10617
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
10318
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7045
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5699
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
4096
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3148
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.