473,387 Members | 1,582 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,387 software developers and data experts.

Use of "Max" in query grid

Good day, and thank you in advance for any assistance you can provide.

I have a table in an Access 2000 .mdb file, and I've run into something odd
and insolvable, at least for me. The database is for membership information.
This particular table, called tblMembershipInfo, has fields/columns as
follows -

fldMemNum - Member Number
fldActionDate - The date when the entry was made in that row - Data type is
Date/Time, no format specified
fldAction - What the entry is for (new membership, adjustment to exp. date,
renewal, etc.)
fldMembershipType - A code telling me if it's a three month, six month or
one year membership and so forth; there are a number of different codes
fldStartDate - The starting date of the membership - Data type is Date/Time,
no format specified
fldExpDate - The expiration date of the membership - Data type is Date/Time,
no format specified

This table, along with a table of stuff like member names and addresses, is
used to generate a mess of reports, membership cards, promotional lists and
the like. That table is called tblMemberInfo; it is the "one" side of a
"one-to-many" relationship with tblmembershipInfo.

In the past, I've used the "Max" function (on the field called "fldExpDate"
in a query to get people's expiration dates, based on the highest expiration
date for the members from the same table. That query has run reliably for
better than a year and I've checked it a couple of times, at random, against
the contents of the tables.

I now want to get people's expiration dates from the most recent record in
the table for any given member. This seemed simple (famous last words) -
here's the SQL I'm trying now, which comes from the SQL page of the QBE
grid -

SELECT tblMemberInfo.fldMemNum, tblMemberInfo.fldFirstName,
tblMemberInfo.fldLastName, Max(tblMembershipInfo.fldActionDate) AS
MaxOffldActionDate, tblMembershipInfo.fldExpDate
FROM tblMemberInfo INNER JOIN tblMembershipInfo ON tblMemberInfo.fldMemNum =
tblMembershipInfo.fldMemNum
GROUP BY tblMemberInfo.fldMemNum, tblMemberInfo.fldFirstName,
tblMemberInfo.fldLastName, tblMembershipInfo.fldExpDate
ORDER BY tblMemberInfo.fldMemNum;

and the query returns all of the entries in the table (about 700, as some
members have two to five entries), including multiple records for those
member numbers that have multiple records. Again, all I want is the
expiration date from the last entry, based on the most recent Action Date in
the table, for any one of the members. I should wind up with a list of
members about 100-110 names long, each with an expiration date after the
date on which the query is run.

I know that my inexperience is causing me to overlook something. I've
checked randomly selected rows to see that the data is true to the date
type - no spaces, blanks and the like. I've made sure that the data types
agree from one table to the next. but I don't see the cause of this. Can
someone point me in the correct direction?

Many thanks.
Steve E.
Nov 13 '05 #1
3 2070
I think that the problem may be including the tblMembershipInfo.fldExpDate
in your query. There will be a different value for each
tblMembershipInfo.fldActionDate

Could be wrong though

Phil

"Serious_Practitioner" <Se************************@att.net> wrote in message
news:Jb*********************@bgtnsc04-news.ops.worldnet.att.net...
Good day, and thank you in advance for any assistance you can provide.

I have a table in an Access 2000 .mdb file, and I've run into something
odd and insolvable, at least for me. The database is for membership
information. This particular table, called tblMembershipInfo, has
fields/columns as follows -

fldMemNum - Member Number
fldActionDate - The date when the entry was made in that row - Data type
is Date/Time, no format specified
fldAction - What the entry is for (new membership, adjustment to exp.
date, renewal, etc.)
fldMembershipType - A code telling me if it's a three month, six month or
one year membership and so forth; there are a number of different codes
fldStartDate - The starting date of the membership - Data type is
Date/Time, no format specified
fldExpDate - The expiration date of the membership - Data type is
Date/Time, no format specified

This table, along with a table of stuff like member names and addresses,
is used to generate a mess of reports, membership cards, promotional lists
and the like. That table is called tblMemberInfo; it is the "one" side of
a "one-to-many" relationship with tblmembershipInfo.

In the past, I've used the "Max" function (on the field called
"fldExpDate" in a query to get people's expiration dates, based on the
highest expiration date for the members from the same table. That query
has run reliably for better than a year and I've checked it a couple of
times, at random, against the contents of the tables.

I now want to get people's expiration dates from the most recent record in
the table for any given member. This seemed simple (famous last words) -
here's the SQL I'm trying now, which comes from the SQL page of the QBE
grid -

SELECT tblMemberInfo.fldMemNum, tblMemberInfo.fldFirstName,
tblMemberInfo.fldLastName, Max(tblMembershipInfo.fldActionDate) AS
MaxOffldActionDate, tblMembershipInfo.fldExpDate
FROM tblMemberInfo INNER JOIN tblMembershipInfo ON tblMemberInfo.fldMemNum
= tblMembershipInfo.fldMemNum
GROUP BY tblMemberInfo.fldMemNum, tblMemberInfo.fldFirstName,
tblMemberInfo.fldLastName, tblMembershipInfo.fldExpDate
ORDER BY tblMemberInfo.fldMemNum;

and the query returns all of the entries in the table (about 700, as some
members have two to five entries), including multiple records for those
member numbers that have multiple records. Again, all I want is the
expiration date from the last entry, based on the most recent Action Date
in the table, for any one of the members. I should wind up with a list of
members about 100-110 names long, each with an expiration date after the
date on which the query is run.

I know that my inexperience is causing me to overlook something. I've
checked randomly selected rows to see that the data is true to the date
type - no spaces, blanks and the like. I've made sure that the data types
agree from one table to the next. but I don't see the cause of this. Can
someone point me in the correct direction?

Many thanks.
Steve E.

Nov 13 '05 #2
Hi, Phil -

Thank you.

I guess I didn't understand the meaning of the term "Max". I thought I'd get
the row with the highest Action date for each member, and then get the Exp
date from that. I followed your suggestion - I took the ExpDate out and I
now get the most recent Action dates - I'll make another query to extract
the most recent Exp Date. Thank you for helping me move on.
Steve E.

"Phil Stanton" <ph******@xxstantonfamily.co.uk> wrote in message
news:42***********************@ptn-nntp-reader02.plus.net...
I think that the problem may be including the tblMembershipInfo.fldExpDate
in your query. There will be a different value for each
tblMembershipInfo.fldActionDate

Could be wrong though

Phil

"Serious_Practitioner" <Se************************@att.net> wrote in
message news:Jb*********************@bgtnsc04-news.ops.worldnet.att.net...
Good day, and thank you in advance for any assistance you can provide.

I have a table in an Access 2000 .mdb file, and I've run into something
odd and insolvable, at least for me. The database is for membership
information. This particular table, called tblMembershipInfo, has
fields/columns as follows -

fldMemNum - Member Number
fldActionDate - The date when the entry was made in that row - Data type
is Date/Time, no format specified
fldAction - What the entry is for (new membership, adjustment to exp.
date, renewal, etc.)
fldMembershipType - A code telling me if it's a three month, six month or
one year membership and so forth; there are a number of different codes
fldStartDate - The starting date of the membership - Data type is
Date/Time, no format specified
fldExpDate - The expiration date of the membership - Data type is
Date/Time, no format specified

This table, along with a table of stuff like member names and addresses,
is used to generate a mess of reports, membership cards, promotional
lists and the like. That table is called tblMemberInfo; it is the "one"
side of a "one-to-many" relationship with tblmembershipInfo.

In the past, I've used the "Max" function (on the field called
"fldExpDate" in a query to get people's expiration dates, based on the
highest expiration date for the members from the same table. That query
has run reliably for better than a year and I've checked it a couple of
times, at random, against the contents of the tables.

I now want to get people's expiration dates from the most recent record
in the table for any given member. This seemed simple (famous last
words) - here's the SQL I'm trying now, which comes from the SQL page of
the QBE grid -

SELECT tblMemberInfo.fldMemNum, tblMemberInfo.fldFirstName,
tblMemberInfo.fldLastName, Max(tblMembershipInfo.fldActionDate) AS
MaxOffldActionDate, tblMembershipInfo.fldExpDate
FROM tblMemberInfo INNER JOIN tblMembershipInfo ON
tblMemberInfo.fldMemNum = tblMembershipInfo.fldMemNum
GROUP BY tblMemberInfo.fldMemNum, tblMemberInfo.fldFirstName,
tblMemberInfo.fldLastName, tblMembershipInfo.fldExpDate
ORDER BY tblMemberInfo.fldMemNum;

and the query returns all of the entries in the table (about 700, as some
members have two to five entries), including multiple records for those
member numbers that have multiple records. Again, all I want is the
expiration date from the last entry, based on the most recent Action Date
in the table, for any one of the members. I should wind up with a list of
members about 100-110 names long, each with an expiration date after the
date on which the query is run.

I know that my inexperience is causing me to overlook something. I've
checked randomly selected rows to see that the data is true to the date
type - no spaces, blanks and the like. I've made sure that the data types
agree from one table to the next. but I don't see the cause of this. Can
someone point me in the correct direction?

Many thanks.
Steve E.


Nov 13 '05 #3
Hi, Phil -

Thank you.

I guess I didn't understand the meaning of the term "Max". I thought I'd get
the row with the highest Action date for each member, and then get the Exp
date from that. I followed your suggestion - I took the ExpDate out and I
now get the most recent Action dates - I'll make another query to extract
the most recent Exp Date. Thank you for helping me move on.
Steve E.

"Phil Stanton" <ph******@xxstantonfamily.co.uk> wrote in message
news:42***********************@ptn-nntp-reader02.plus.net...
I think that the problem may be including the tblMembershipInfo.fldExpDate
in your query. There will be a different value for each
tblMembershipInfo.fldActionDate

Could be wrong though

Phil

"Serious_Practitioner" <Se************************@att.net> wrote in
message news:Jb*********************@bgtnsc04-news.ops.worldnet.att.net...
Good day, and thank you in advance for any assistance you can provide.

I have a table in an Access 2000 .mdb file, and I've run into something
odd and insolvable, at least for me. The database is for membership
information. This particular table, called tblMembershipInfo, has
fields/columns as follows -

fldMemNum - Member Number
fldActionDate - The date when the entry was made in that row - Data type
is Date/Time, no format specified
fldAction - What the entry is for (new membership, adjustment to exp.
date, renewal, etc.)
fldMembershipType - A code telling me if it's a three month, six month or
one year membership and so forth; there are a number of different codes
fldStartDate - The starting date of the membership - Data type is
Date/Time, no format specified
fldExpDate - The expiration date of the membership - Data type is
Date/Time, no format specified

This table, along with a table of stuff like member names and addresses,
is used to generate a mess of reports, membership cards, promotional
lists and the like. That table is called tblMemberInfo; it is the "one"
side of a "one-to-many" relationship with tblmembershipInfo.

In the past, I've used the "Max" function (on the field called
"fldExpDate" in a query to get people's expiration dates, based on the
highest expiration date for the members from the same table. That query
has run reliably for better than a year and I've checked it a couple of
times, at random, against the contents of the tables.

I now want to get people's expiration dates from the most recent record
in the table for any given member. This seemed simple (famous last
words) - here's the SQL I'm trying now, which comes from the SQL page of
the QBE grid -

SELECT tblMemberInfo.fldMemNum, tblMemberInfo.fldFirstName,
tblMemberInfo.fldLastName, Max(tblMembershipInfo.fldActionDate) AS
MaxOffldActionDate, tblMembershipInfo.fldExpDate
FROM tblMemberInfo INNER JOIN tblMembershipInfo ON
tblMemberInfo.fldMemNum = tblMembershipInfo.fldMemNum
GROUP BY tblMemberInfo.fldMemNum, tblMemberInfo.fldFirstName,
tblMemberInfo.fldLastName, tblMembershipInfo.fldExpDate
ORDER BY tblMemberInfo.fldMemNum;

and the query returns all of the entries in the table (about 700, as some
members have two to five entries), including multiple records for those
member numbers that have multiple records. Again, all I want is the
expiration date from the last entry, based on the most recent Action Date
in the table, for any one of the members. I should wind up with a list of
members about 100-110 names long, each with an expiration date after the
date on which the query is run.

I know that my inexperience is causing me to overlook something. I've
checked randomly selected rows to see that the data is true to the date
type - no spaces, blanks and the like. I've made sure that the data types
agree from one table to the next. but I don't see the cause of this. Can
someone point me in the correct direction?

Many thanks.
Steve E.


Nov 13 '05 #4

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

Similar topics

0
by: Steve | last post by:
Hi, Is there something fundamentally wrong with the following query? SELECT MAX(OrderID) AS Expr1 FROM Orders WHERE (MarketActionCode = 'S') AND (OrderLegCode = 'S') AND (Status = 'F') AND...
2
by: Alpha | last post by:
I need to find the file and its file name in a directory where the filename is made up with XXXYYYYMMDDXXX.mdb The date is embedded in the middle of the file name. The prefix and postfix of...
1
by: Vladimir Davidov | last post by:
Hello everybody! I realize that the problem, I will ask for solution of, has been posted here once, but none of the replies would actually solve it. So I will try again - there is one project,...
8
by: abcd | last post by:
I can get the value on the form at the server side by using Request.form("max") when max field is disabled I dont get value. For GUI and business logic purpose I have disabled some fields with...
1
by: Thomas Qi | last post by:
There is a basic sql below: SELECT CTEnr AS ID, TimeStamp, DatagramSize, Source AS LocalIP, Destination AS RemoteIP, Protocol, Messages, SourcePort AS LocalPort, DestPort AS RemotePort FROM...
10
by: JDT | last post by:
Hi, Can someone provide me an example that uses std::max_element() (probablly the predicate version) to return the max "absolute" integer in a vector? Your help is much appreciated. Tony ...
3
by: lawrence k | last post by:
This is weird. When I use getId3 to try to read meta tags out of multimedia files, I get this error: Fatal error: Maximum execution time of 30 seconds exceeded in /home/...
3
by: jclover | last post by:
When creating a query in Access (assumption is the data has a unique ID which is numerical...new records, autonumber) how reliable is the "Last of" grouping function vs the "Max of" the ID, and then...
10
by: anonymous | last post by:
How can I set report output parameter "Page 1 of max" to get output on first page in minimum time as it takes much time in fetching max page no. in first page and report is of around million pages
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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...
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...
0
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,...
0
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...
0
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,...
0
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...

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.