473,383 Members | 2,005 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,383 software developers and data experts.

Filter A record with date lower than MaxDate

99 64KB
I have Two Tables:

Stduents:
Expand|Select|Wrap|Line Numbers
  1. ID     Name     DOB
  2. ==========================
  3. 1      XYZ      01/01/2000
  4.  
Admissions:
Expand|Select|Wrap|Line Numbers
  1. AdmissionID   Admission No    Date of Admission     StudentID
  2. ==============================================================
  3. 1             1234            25/05/2016            1
  4. 2             4567            28/04/2015            1
  5. 3             7890            25/08/2015            1
  6.  
Both the tables are related with
Admissions.StudentID = Students.ID

Now the question is that I want a query resulting in a record like:

Expand|Select|Wrap|Line Numbers
  1. StudentID    Name      AdmissionID    Date of Admission     Admissoin No
  2. ========================================================================
  3. 1            XYZ       3              25/08/2015            7890
  4.  
Where the Date of Admission is just lesser than than maximum date of admission.
I know that that the maximum date of admission can be found using max(date of admission).
But the help is needed for the record containing the second last date of admission. Thanking in anticipation.
May 25 '16 #1
1 949
PhilOfWalton
1,430 Expert 1GB
This should work, but you will need to change my Member... to Student... and Payment... to Admission...

Be aware that if a student has only 1 admission date, the previous date will be blank.

Expand|Select|Wrap|Line Numbers
  1. SELECT Payments.MemberID, Payments.PaymentDate, Member.MemSurName, 
  2. DMax("PaymentDate","Payments","MemberID = " & [Member]![MemberID]) AS MaxDate, 
  3. DMax("PaymentDate","Payments","MemberID = " & [Member]![MemberID] & "And PaymentDate < #" & [MaxDate] & "#") AS PrevDate
  4. FROM Payments INNER JOIN Member ON Payments.MemberID = Member.MemberID;
  5.  
So Maxdate is the last addmission date. Then we find the maximum admission date for that student where the date is less than the MaxDate just found

Phil
May 25 '16 #2

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

Similar topics

4
by: S. van Beek | last post by:
Dear reader, By a Date field with Now() as default value the content of the field is date plus time. As I need a filter in a query on date only (excluding time) I invented the following...
1
by: colleen1980 | last post by:
I create two fields in my old table. One is D_Status of type Yes/No Checkbox and the other is DDate of type Date. In my table there is already records in it. I set the default value of DDate as...
1
by: jon everly | last post by:
I have Excel 2003 and am using the Microsft Query function to pull in data via SQL from a database. However, I want to set a filter on the data that only pulls in dates between Today and 14 days...
3
by: dbdb | last post by:
hi guys need your suggestion how can i apply filter for my date variable data type i have a form name transaction and i have a text box on it named : start and finish i need to apply...
2
by: simon penny | last post by:
I have a table in which I record referral records. I have a second table in which I record service records. One referral can have many service records attached. The tables are linked by referral ID -...
1
by: gdyoung | last post by:
I'm building a database and am having troubles opening a form with a filter. I've tried a few things but nothing seems to be doing what I want. Here's a stop gap solution that at least displays...
6
yosiro
by: yosiro | last post by:
In my attachment (file access 2010) I want to show some information from a form but i don't know how to write code on query or on a form load. Described here: I want to make report that run...
1
by: kaug | last post by:
I have created a report using report viewer to show the record of all employee. I want to filter the record of all employee in a certain department. I want to filter this record as i type the...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.