473,591 Members | 2,871 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problems Querying Last Donation in Donation Table

Hi all!

I have an Access 2000 database for the Habiat for Humanity where I work.
This is the second database I have written and it gets a bit more complex
each time... I have learned much and read much over the last few months and
have found leads to the answers to several other problems I have encountered
with a Google search of past posts/threads.
SO thank you for the help already rendered even though you didn't know!!

My problem is this I want to pull a query with just the LAST donation from
all donors (as opposed to just the "last donation")
The data is stored in two tables tblCntc and tblDonations
I can pull everything together with query called QryCntcDonation sLast and
set the "total" to Last and get ALMOST what I need.
SQL reads:
SELECT tblCntc.CntcID, tblCntc.Cntc1Fi rstName, tblCntc.Cntc1La stName,
tblCntc.CntcOrg anization, Last(tblDNDonat ions.DNDate) AS LastOfDNDate
FROM tblDNDonations INNER JOIN tblCntc ON tblDNDonations. DNID =
tblCntc.CntcID
GROUP BY tblCntc.CntcID, tblCntc.Cntc1Fi rstName, tblCntc.Cntc1La stName,
tblCntc.CntcOrg anization;

As it is written this works fine - but what I NEED are additional fields
from the tblDonations like amount, purpose, etc. WHEN I add ANYoff these
the LAST element appears to not work and the query begins to return more
than just the LAST donation from donors.

I have read several posts about the dmax or max and have tried several of
the suggestions but they don't seem to work and return either all the
donations or don't work.

ANY help will be appreciated. I have spent several hours over the last few
evenings and have not had any sucess.

Thanks

Andy

FYI: My next step is to add a volunteer scheduling component and will need a
similar query for when volunteers were last scheduled.
Nov 12 '05 #1
3 2016
I think if you have 1 query (Query1) just returning the CntcID and the
LastOfDNDate, and then create a second query with whatever information you
want. That would consist of your 2 table + Query 1 but join the 2 CntcIDs
and the LastOfDNDate to the DNDate. That should only pull information
applicable to the last donation date
HTH

Phil
"AndyBell" <jb***@NOSPAMle ecountyhabitat. org> wrote in message
news:vv******** ****@corp.super news.com...
Hi all!

I have an Access 2000 database for the Habiat for Humanity where I work.
This is the second database I have written and it gets a bit more complex
each time... I have learned much and read much over the last few months and have found leads to the answers to several other problems I have encountered with a Google search of past posts/threads.
SO thank you for the help already rendered even though you didn't know!!

My problem is this I want to pull a query with just the LAST donation from
all donors (as opposed to just the "last donation")
The data is stored in two tables tblCntc and tblDonations
I can pull everything together with query called QryCntcDonation sLast and
set the "total" to Last and get ALMOST what I need.
SQL reads:
SELECT tblCntc.CntcID, tblCntc.Cntc1Fi rstName, tblCntc.Cntc1La stName,
tblCntc.CntcOrg anization, Last(tblDNDonat ions.DNDate) AS LastOfDNDate
FROM tblDNDonations INNER JOIN tblCntc ON tblDNDonations. DNID =
tblCntc.CntcID
GROUP BY tblCntc.CntcID, tblCntc.Cntc1Fi rstName, tblCntc.Cntc1La stName,
tblCntc.CntcOrg anization;

As it is written this works fine - but what I NEED are additional fields
from the tblDonations like amount, purpose, etc. WHEN I add ANYoff these
the LAST element appears to not work and the query begins to return more
than just the LAST donation from donors.

I have read several posts about the dmax or max and have tried several of
the suggestions but they don't seem to work and return either all the
donations or don't work.

ANY help will be appreciated. I have spent several hours over the last few evenings and have not had any sucess.

Thanks

Andy

FYI: My next step is to add a volunteer scheduling component and will need a similar query for when volunteers were last scheduled.

Nov 12 '05 #2
as a quick test, I created tblOne
id (pk)
lastName

id lastname
1 cane
2 able

and tblTwo
id (pk) (uk)
seq (pk)
date (uk)
donation

id seq date donation
1 1 1/3/2004 8
1 2 1/4/2004 9
2 1 1/5/2004 10
2 2 1/6/2004 11

since you want the donation for the last date, I assume that every
date in tblTwo is unique ?

then I created qry2
SELECT tblTwo.id, Last(tblTwo.dat e) AS LastOfdate
FROM tblTwo
GROUP BY tblTwo.id;

id lastDate
1 1/4/2004
2 1/6/2004
then I created qry1
SELECT tblOne.lastName , qry2.LastOfdate , tblTwo.donation
FROM (tblOne INNER JOIN qry2 ON tblOne.id = qry2.id) INNER JOIN
tblTwo ON
(qry2.LastOfdat e = tblTwo.date) AND (qry2.id = tblTwo.id);
^^^^ - this is based on my assumption above

lastName lastDate donation
cane 1/4/2004 9
able 1/6/2004 11

is this what you need ?
if my assumption is incorrect, which donation amount would you want
for id 2 ?
id seq date donation
1 1 1/3/2004 8
1 2 1/4/2004 9
2 1 1/5/2004 10
2 2 1/5/2004 11

"AndyBell" <jb***@NOSPAMle ecountyhabitat. org> wrote in message news:<vv******* *****@corp.supe rnews.com>...
Hi all!

I have an Access 2000 database for the Habiat for Humanity where I work.
This is the second database I have written and it gets a bit more complex
each time... I have learned much and read much over the last few months and
have found leads to the answers to several other problems I have encountered
with a Google search of past posts/threads.
SO thank you for the help already rendered even though you didn't know!!

My problem is this I want to pull a query with just the LAST donation from
all donors (as opposed to just the "last donation")
The data is stored in two tables tblCntc and tblDonations
I can pull everything together with query called QryCntcDonation sLast and
set the "total" to Last and get ALMOST what I need.
SQL reads:
SELECT tblCntc.CntcID, tblCntc.Cntc1Fi rstName, tblCntc.Cntc1La stName,
tblCntc.CntcOrg anization, Last(tblDNDonat ions.DNDate) AS LastOfDNDate
FROM tblDNDonations INNER JOIN tblCntc ON tblDNDonations. DNID =
tblCntc.CntcID
GROUP BY tblCntc.CntcID, tblCntc.Cntc1Fi rstName, tblCntc.Cntc1La stName,
tblCntc.CntcOrg anization;

As it is written this works fine - but what I NEED are additional fields
from the tblDonations like amount, purpose, etc. WHEN I add ANYoff these
the LAST element appears to not work and the query begins to return more
than just the LAST donation from donors.

I have read several posts about the dmax or max and have tried several of
the suggestions but they don't seem to work and return either all the
donations or don't work.

ANY help will be appreciated. I have spent several hours over the last few
evenings and have not had any sucess.

Thanks

Andy

FYI: My next step is to add a volunteer scheduling component and will need a
similar query for when volunteers were last scheduled.

Nov 12 '05 #3
Phil & Roger,
Thanks for your help.
Phil had the right answer,[twin/dbl join] but something Roger said tipped me
off to my mistake. "I assume that every date in tblTwo is unique"

The donations table has about 900 records. When drilled down with the Last
query it returns about 350 records - one date for each donor -however what
was throwing me off was that many donors have multiple donations on the SAME
day....

Had I realized this 18 months ago I would have created a "donation date"
table with related "donated items" table... [so now I have to wrestle with
changing that data "for the long term good" or "its not that important"]

Thanks again!
Andy

"Roger" <le*********@na tpro.com> wrote in message
news:8c******** *************** ***@posting.goo gle.com...
as a quick test, I created tblOne
id (pk)
lastName

id lastname
1 cane
2 able

and tblTwo
id (pk) (uk)
seq (pk)
date (uk)
donation

id seq date donation
1 1 1/3/2004 8
1 2 1/4/2004 9
2 1 1/5/2004 10
2 2 1/6/2004 11

since you want the donation for the last date, I assume that every
date in tblTwo is unique ?

then I created qry2
SELECT tblTwo.id, Last(tblTwo.dat e) AS LastOfdate
FROM tblTwo
GROUP BY tblTwo.id;

id lastDate
1 1/4/2004
2 1/6/2004
then I created qry1
SELECT tblOne.lastName , qry2.LastOfdate , tblTwo.donation
FROM (tblOne INNER JOIN qry2 ON tblOne.id = qry2.id) INNER JOIN
tblTwo ON
(qry2.LastOfdat e = tblTwo.date) AND (qry2.id = tblTwo.id);
^^^^ - this is based on my assumption above

lastName lastDate donation
cane 1/4/2004 9
able 1/6/2004 11

is this what you need ?
if my assumption is incorrect, which donation amount would you want
for id 2 ?
id seq date donation
1 1 1/3/2004 8
1 2 1/4/2004 9
2 1 1/5/2004 10
2 2 1/5/2004 11

"AndyBell" <jb***@NOSPAMle ecountyhabitat. org> wrote in message

news:<vv******* *****@corp.supe rnews.com>...
Hi all!

I have an Access 2000 database for the Habiat for Humanity where I work.
This is the second database I have written and it gets a bit more complex each time... I have learned much and read much over the last few months and have found leads to the answers to several other problems I have encountered with a Google search of past posts/threads.
SO thank you for the help already rendered even though you didn't know!!

My problem is this I want to pull a query with just the LAST donation from all donors (as opposed to just the "last donation")
The data is stored in two tables tblCntc and tblDonations
I can pull everything together with query called QryCntcDonation sLast and set the "total" to Last and get ALMOST what I need.
SQL reads:
SELECT tblCntc.CntcID, tblCntc.Cntc1Fi rstName, tblCntc.Cntc1La stName,
tblCntc.CntcOrg anization, Last(tblDNDonat ions.DNDate) AS LastOfDNDate
FROM tblDNDonations INNER JOIN tblCntc ON tblDNDonations. DNID =
tblCntc.CntcID
GROUP BY tblCntc.CntcID, tblCntc.Cntc1Fi rstName, tblCntc.Cntc1La stName,
tblCntc.CntcOrg anization;

As it is written this works fine - but what I NEED are additional fields
from the tblDonations like amount, purpose, etc. WHEN I add ANYoff these the LAST element appears to not work and the query begins to return more
than just the LAST donation from donors.

I have read several posts about the dmax or max and have tried several of the suggestions but they don't seem to work and return either all the
donations or don't work.

ANY help will be appreciated. I have spent several hours over the last few evenings and have not had any sucess.

Thanks

Andy

FYI: My next step is to add a volunteer scheduling component and will need a similar query for when volunteers were last scheduled.

Nov 12 '05 #4

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

Similar topics

7
32937
by: Marc Pelletier | last post by:
Hello, I have a table with a Day field, defined as smalldatetime. I am filling it from a CSharp application with the following code: DataRow r = dtStaDays.NewRow(); r= station_ID; r = sd.Date; r = rangeTide; etc.
3
3148
by: daveland | last post by:
I am working on some JavaScript that dynamically adds rows to a table in response to a button click. A new row does appear on the screen when the button is clicked. However, that table to which a row has been added is itself contained within an outer table (to handle the desired screen layout). That outer table does not properly grow to contain the new size of the table to which the row was added. (More specifically, I have...
5
2362
by: Shane | last post by:
I wonder if someone has any ideas about the following. I am currently producing some reports for a manufacturing company who work with metal. A finished part can contain multiple sub-parts to make up the finished part. The sub-parts can also be made up of sub-parts and those sub-parts can also be made up of sub-parts etc etc. All parts are contained within the same table and I have a seperate table
8
10305
by: Jean | last post by:
Hello all, I have the following data, that was queried and sorted to columns PROBLEM_ID and then by STATUSDATE (ascending): STATUS_ID STATUSDATE PROBLEM_ID --------- ---------- ---------- 10 12/04/2005 1234 40 15/05/2005 1234
4
1510
by: pietlinden | last post by:
Hi, I have the sort of standard Donors/Donations DB. The twist I have is that donations can be time, money (which are easy, because they're additive), but then a donor can make an in-kind pledge, of say 3 chairs and a table. Normally, in subclassing the donation, I would end up with something like this: standard donor DB of just money/time:
3
1573
by: MDB | last post by:
I'd normally Google for a question like this, and hope to snag a few examples along with the answer, but this time I can't see to get the keywords specific enough. Or I'd ask coworkers, but they're just as new to ASP.NET as I am. Is it possible to have a dataset filled with all the records in an SQL table (on the small side, maybe three hundred records total), and then query that table for subsets of data, e.q. a simple WHERE clause,...
1
4741
by: Andrew | last post by:
Hey all, Working on revamping our Intranet here and making use of the LDPA, Active Directory, Directory Services, etc. that .Net provides. I am still fairly new on this subject, so the problem I have run into I am not sure how to fix, and really not sure what is causing it. Here's what is going on (test server - Windows 2003 Server): I have a page in a folder (under anonymous authentication in IIS6) that has a link on it that...
2
2153
by: bwana.mpoa | last post by:
Hi, We're using a mySQL database as a replica of another (Sybase) DB for reporting purposes. The Sybase is part of a real-time mission critical system - hence the separate database where people can run their queries on. Currently a separate application is copying the information we're interested in from Sybase to mySQL in an overnight batch-process. We want to extend this to loading every 15 minutes and are now investigating the...
2
1735
by: RajSharma | last post by:
Hi, I am facing a problem regarding querying thru a large table having millions of rows....... Its hanging in between while querying for all those rows Can anybody suggest me a query regarding : Querying the database everytime for next 100 records ( that means i need to set up a cursor) till the count of the table rows ends up(take 1 million rows e.g.) The database is DB2
0
7934
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
7870
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
8236
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...
1
7992
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,...
0
8225
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
6639
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
5732
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
3891
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1199
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.