I have a table containing the following fields:
ProjectUpdateID (PrimaryKey)
ProjectID
UpdateDate
I would like to create a Query in Ms Access 2000 which will return me
the most recent 2 records (and also show the above 3 fields)
So suppose the table looks like this:
ProjectUpdateID , ProjectID, UpdateDate
1,119,2/13/1999
2,119,2/24/2000
3,119,1/19/1998
4,119,1/21/2003
5,120,8/22/2001
6,120,9/12/2002
7,120,9/11/2001
The Resulting query should return the following, because these are the
2 most recent records "for each project ID":
ProjectUpdateID , ProjectID, UpdateDate
4,119,1/21/2003
2,119,2/24/2000
6,120,9/12/2002
7,120,9/11/2001
I was able to get it to work for "THE" most recent date by projectID,
by not including ProjectUpdateID in the query, and using "MAX", but as
soon as I include the ProjectUpdateID field in immediately expands and
return all the records for that ProjectID.
Please Help ? Is there a function I don't know about ?
Please email me as well as post.
Best
Shai ny****@yahoo.co m 2 3869
To return the most recent record entered you can use a Group By query
and and in the Totals row select the Last function (aggragate function)
for your ID field. The Last function returns the last record entered.
Note: if you have a date field and 8/1/03 was entered before the record
with 7/1/03, and the record with 7/1/03 was the last record entered,
that it the record that will be returned with the Last function. you
could set criteria for a date field like select the last record entered
between 7/1/03 and 8/1/03. For the second to last record, unless you
have some key field for ranking records by order of first to last, you
will have to set up your own criteria, or maybe add a new field for
ranking the records.
Rich
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
"Shaiguy" <ny****@yahoo.c om> wrote in message
news:81******** *************** ***@posting.goo gle.com... I have a table containing the following fields:
ProjectUpdateID (PrimaryKey) ProjectID UpdateDate
I would like to create a Query in Ms Access 2000 which will return me the most recent 2 records (and also show the above 3 fields)
So suppose the table looks like this: ProjectUpdateID , ProjectID, UpdateDate 1,119,2/13/1999 2,119,2/24/2000 3,119,1/19/1998 4,119,1/21/2003 5,120,8/22/2001 6,120,9/12/2002 7,120,9/11/2001
The Resulting query should return the following, because these are the 2 most recent records "for each project ID":
ProjectUpdateID , ProjectID, UpdateDate 4,119,1/21/2003 2,119,2/24/2000 6,120,9/12/2002 7,120,9/11/2001
This is aircode but something like this should do it:
-----------------------------------------------------------
select a1.ProjectUpdat eID, a1.ProjectID, a1.UpdateDate
from
(
select ProjectUpdateID , ProjectID, UpdateDate
from mytable
group by ProjectUpdateID , ProjectID, UpdateDate
) as a1
inner join
(
select ProjectUpdateID , ProjectID, UpdateDate
from mytable
group by ProjectUpdateID , ProjectID, UpdateDate
) as a2
on a1.ProjectID = a2.ProjectID
and a1.UpdateDate <= a2.ProjectDate
group by a1.ProjectUpdat eID, a1.ProjectID, a1.UpdateDate
having count(*) <3
order by a1.ProjectID, a1.UpdateDate desc
---------------------------------------------------------- This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Nova's Taylor |
last post by:
Hi folks,
I am a newbie to Python and am hoping that someone can get me started
on a log parser that I am trying to write.
The log is an ASCII file that contains a process identifier (PID),
username, date, and time field like this:
1234 williamstim 01AUG03 7:44:31
2348 williamstim 02AUG03 14:11:20
|
by: Randy Jackson |
last post by:
First of all, I apologize in advance if this is covered somewhere in a
FAQ. I did a Google search, but really couldn't find anything.
I'm having a problem with a simple select query. I've got users
uploading data into a database. I want to do something that seems as if
it should be really simple, but it isn't so far.
Basically, I want to retrieve the latest 12 records from the table,
sorted by the date-time field (uploaddate) then...
|
by: Tim Graichen |
last post by:
Good morning,
I have a sub-form that displays records from a table as a continuous form.
The table has several hundred records, but the subform only displays five or
six records. The records do include a date field.
How can I force the sub form to display the most recent dates by default,
verses forcing the user to scroll through all of the records to the bottom
of the form in order to view the most recent entry or to add a new entry...
|
by: Robin S. |
last post by:
**Eric and Salad - thank you both for the polite kick in the butt. I hope
I've done a better job of explaining myself below.
I am trying to produce a form to add products to a table (new products).
Tables:
tblCategoryDetails
CategoryID
SpecID
|
by: perryche |
last post by:
Experts,
I have the following scenario:
Table1: RecordID RecordDate ...
I want in a query to show me within this RecordID, only the latest
RecordDate and info. I know I can use the Max command but am not
familiar with the concept behind it, how to use it. i.e. if I pick
Max(RecordDate) in the query column, it still shows all records. If I
combine it with RecordID, same... what should I have done?
| |
by: Jason H |
last post by:
Hi,
I am sure I am just overlooking the obvious, but I am having a little trouble with this one...
I am setting up an inventory database that tracks company tools and their location. This database has a table tblToolInfo and another table tblTransferHistory which are linked by a Tool ID field. As tools are checked out they are recorded in tbl TransferHistory based on ID, location taken from, location taken to, authorizing person, and date....
|
by: robert.waters |
last post by:
I need to perform the following:
- select the most recent X number of records in a table (there is a
timestamp field)
- select the Nth occurrence of X number of records
ex:
- most recent 10 records (N is 1)
- most recent records 10-20 (N would be 2)
- most recent records 10-30 (etc.)
|
by: mcca0081 |
last post by:
hi - i'm trying to delete one of the duplicate records based on the
most current date.
here's the code for my access 2000 db. any help would be
appreciated!!! - thank you kindly
Sub DeleteDuplicateRecords()
' Deletes duplicates from the specified table, keeping the most
current received date record.
' No user confirmation is required.
|
by: Dr Al |
last post by:
I have a table with four date fields, some of which may not be filled
in based on our data entry needs. I have a criteria set as <date()-180
which is supposed to pull dates older than 180 days ago. The problem
is that when I use that criteria for all four fields I am not getting
the expected results.
I am trying to find out from this query is the date in date field one
is older than 180, same thing for the other three date fields. For...
|
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...
|
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,...
| |
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...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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...
|
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...
|
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();...
|
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...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |