I have a problem here that I've been wrestling with for a while.I have a table, ID, Date, and Grade.It is set up that way, and I tried
Code:
SELECT tblGrades.StudentID, tblGrade.Grade, Max(tblGrade.GradeDay)
FROM tblGrades
GROUP BY tbGrades.StudentID, tblGrades.Grade;
I figured since I'm grouping by both StudentID and Grade, it wont return the most recent grade from that Student. Is there any way for me to NOT group by Grade and just display the results of the Max(GradeDay?)
Code: tblequipment equipmentid equipmentnumber (user defined ID)
tblrentals rentalid rentaldate rentaltime fromparty (c for customer, e for employee, o for other) frompartyid (foriegn key to either customer, employee or other) toparty (same as from) topartyid (same as from)
tblrentaldetails detailid rentalid equipmentid
How can I get a list of ALL equipment showing the most recent date and time, also showing the respective toparty and topartyid? I can get it fairly easily, except for including toparty and topartyid.
Any way to filter the average price of of a Product within the last 5 occurences (Line Items). It would pull a week back so WHERE: Between Now()-7 and Now(). Example:
I have a table called tbl Meeting Response. It records the data about churches where I have scheduled a representative. Two of the fields in the tbl Meeting Response are 1. Normal Attendance (how many the church normally runs) and 2. Tour Year (the year we were there). Reps have been scheduled at many of these churches more than once over the years, so there are records for different years for the same church in the Meeting Response table.
I want to create a query that will show a field with the most recent normal attendance from the Meeting Response table. This would require comparing the information between two different fields -- Normal Attendance and Tour Year. 1. If a rep was at that church in 2014, 2013 and 2012, and we have a Normal Attendance number for all 3 years, I want the field to show the attendance submitted in 2014 (the most recent). However, if the rep didn't call in a normal attendance in 2014, and the most recent attendance we have is 2012 (i.e., the Normal Attendance is blank for both 2014 and 2013), then I want that field to show the attendance for 2012 (the most recent).
Code: tblPrice PosNr PriceDate Company Price 1 01.01.2014 Firma A 5 2 02.01.2014 Firma A 7 3 03.01.2014 Firma A 9 4 04.01.2014 Firma A 8 5 06.01.2014 Firma A 6 6 02.01.2014 Firma XY 11 7 03.01.2014 Firma XY 9 8 04.01.2014 Firma XY 7 9 05.01.2014 Firma XY 8 10 06.01.2014 Firma XY 10
And I have a table with the dates, for which I need a price.
Code: tblDates PosNr PriceDate Company 1 01.01.2014 Firma A 2 02.01.2014 Firma A 3 03.01.2014 Firma A 4 04.01.2014 Firma A 5 05.01.2014 Firma A (no price available) 6 06.01.2014 Firma A 7 02.01.2014 Firma XY 8 03.01.2014 Firma XY 9 04.01.2014 Firma XY 10 05.01.2014 Firma XY 11 06.01.2014 Firma XY
And now I want to combine this tables, and for the dates which have no price, the last price should be taken.
Code: tblResult PosNr PriceDate Company Price 1 01.01.2014 Firma A 5 2 02.01.2014 Firma A 7 3 03.01.2014 Firma A 9 4 04.01.2014 Firma A 8 5 05.01.2014 Firma A 8 (actualy no priceavailable, so take last price) 6 06.01.2014 Firma A 6 7 02.01.2014 Firma XY 11 8 03.01.2014 Firma XY 9 9 04.01.2014 Firma XY 7 10 05.01.2014 Firma XY 8 11 06.01.2014 Firma XY 10
how I can get this?
I have this code, but it need hours.
Code: SELECT tblDates.PosNr, tblDates.Company, tblDates.PriceDate, (SELECT TOP 1 B.Price FROM tblPrices As B WHERE B.Company = tblDates.Company AND B.PriceDate <= tblDates.PriceDate ORDER BY B.PriceDates DESC ) AS Price FROM tblPrices RIGHT JOIN tblDates ON (tblPrices.PriceDate = tblDates.PriceDates) AND (tblPrices.Company = tblDates.Company);
Here's the scenario. I have 3 fields [AgentID], [QA Date], [Points Issued]. What I want to do is run a query that will give me the last date [QA Date] a point [Points Issued] was issued for each agent [AgentID]. And I want the query to display all 3 fields according. Is this possible?
I need to know if it is possible to make a query that selects the highest or lowest value below or above a number that a user or form defines.
For example, the attached database has a history of which of three children held the position of mom's favorite by recording the day that they became mom's favorite, the idea being that they stayed there until someone replaced them.
It is possible to make a report that would request a date from the user and then would return with who was mom's favorite on that date? Perhaps by checking the records to see which record had the most recent date before the date entered.
Just in case you haven't noticed, this is not the practical application of this concept, I am just trying to find out if it is possible.
I have a database with test scores that I am trying to get the most recent date for. Each student can take a test multiple times, but I only need to see the most recent test score. The tables I am using are one called Students which has the following fields, Grade, Student number, Last name, First Name, and Inactive, and another table called scores with the folowing fields,student number, score, test result, test name and test date. When I do a total query it still shows me multiple records for each student. How can I get this to show only the most recent test score for each test name? I am pretty inexperienced with access, and am totally unfamiliar with expresion builder. If anyone has suggestions I would appreciate it.
This is what my data looks like: Grade Student # Last Name First Name Inactive Score Test Result Test Name Test Date 11 751240 BarretoLuisNo577XSBST Math 2/3/2004 11 751240 BarretoLuisNo611PSBST Math 2/3/2005 11 751240 BarretoLuisNoNTBST Math 2/6/2003
What I would like to have it show is the most recent test date of 2/3/05
Now, what I need is a report that will give the last price of an item. I import the new pricing on to a table once I receive, but not all the items get new princing all the time. This means I can't query for the pricing of a specific date. I need to figure out a query that will give me the LAST or MOST RECENT price entered. Also I can't just sort it out without going through thousand of records to get what I need, that's what I've been doing so far.
My tables are structured right now such that; Table 1 has all the main information and uses a primary key. Table 2 is linked to table one without a primary key, for every row in Table 1 it can have several rows in Table 2. In Table 2, i have a date field.
I want to query information such that, it brings up information for the row in table one and only the most recent row in its corresponding table 2. Most recent indicated by date field.
I've tried some things using Max(date) etc, but to no avail.
I've done querying before, but none as complex as this. What I'm trying to do is query a table for the most recent date (field labeled "Sample Date") for each ID (field lableled "Sample ID"). It is also giving me other output as a sum of my "Results" field. So, in essence, what I want is the total number (sum) of each "Sample ID" for that "Sample ID"'s most recent "Sample Date".
I have a query set up right now where its showing me the sum of "Results" for each "Sample ID", but with multiple "Sample Date"s and "Sample ID"s. I have the "Sample Date" field in descending order, but how do I get it to show only the most recent "Sample Date" for each "Sample ID"?
In my database I have records that are exactly the same except for some dates. My fields consists of the following: “Model Number”, “Serial Number”, “Last Cal Date”, “Cal Due Date” “Days Due” and “Interval”. The Cal Due Date and Days Due are calculated fields in my query. Each time a device has been recalibrated it is logged into the database. Example my torque screwdrivers are to be calibrated every three months. Once the screwdriver has been recalibrated it is logged into the database. The model number stays the same, the serial number stays the same, a new “Last Cal Date” is entered. I select the interval and the “Cal Due Date” and “Days Due” are calculated. Every time calibration is due I repeat this process. So in 1 year I will have 4 records showing that serial number XXXX was calibrated and when. This process is repeated for every piece of test equipment that requires calibration. How can I query to give me the most recent records for the entire database for each unique serial number.
I'm replying because I am having the same sort of problem with my current database. I do have the separate tables like don has described. Basically here is what I have:
Employee table: Employee number (primary key) Other fields for employee information
Training table: (A different table for each training that I am tracking) ID (autonumber - primary key) Employee number Training Date
There is a new entry on the training table each time an employee completes a training. I then have a query that links the 2 tables (using a join between employee number) and calculates next training due dates and filters to overdue training and trainings that are due in the next 30 days. Currently, the query is not pulling in the most recent training dates for each employee. What do I need to do to the query design so that it will only pull in the most recent training date for each employee? Any help would be greatly appreciated.
I'm sure the answer is on here somewhere but trying to find it and then getting it to work is a bit of a problem, so i resorted to posting.
I have 5 tables Partnership Details, Invoices, Funding, Communication, Communication Types.
the field Partnership Name in the Partnership Details table has a one to many relationship with the partnership name on tables: Invoices, Funding and Comunication.
What I want to do is create a query that will show the most recent invoice (detirmined by date) and the most recent funding (detirmined by date) for each partnership.
I can do this using max if I only want the feilds Partnership name, invoice date and funding date. however I want to create a report that will show several feilds from partnership details and I want to show the invoice no. and amount as well as the date and also the amount and notes field for funding
I have a database table comprising inspection records for about 300 process control instruments. A new record is entered for each inspection so that an inspection history builds up for each instrument.
For one report I need to extract all the records with the only the latest inspection date for each instrument.
I attempted to build a query using the design grid screen. Initially I thought I could use the "Max of" approach as I have done with numbers. This did not work so tried without success to convert the dates to serial format thinking I could "Max of".
Have now concluded that a module is needed. However with my Access Basic programming skills this would take me a couple of weeks and still be wrong!
I have two tables: tblA with PersonID field; tblB with PersonID field and AppointmentDates field. Tables are joined on PersonID field. How to run a query which would return all records from tblA and only the most recent date from AppointmentsDates field from tableB?
Do I use GroupBy somewhere or Top 1 to acomplish this? Or maybe I should use a sub-query?
First I just want to say thanks to everyone because you guys are great and have helped me with more than one database. Now for my problem...
I've been searching the forum and reading a lot of the posts about how get the most recent date from a query using Max. My problem is that I don't understand SQL. :confused: So, the stack of papers that I printed out to help me aren't really helping at all. ^_^
I know that I don't necessarily need to understand SQL if I know what to put into it -- so please help!
I need to pull the most recent date from a list of court dates that are updated on a subform of a subform. This way I can print a list of names to watch for in a given week.
The tables involved go as follows:
BaseTable CrtTable CrtSubTab
BaseTable is linked 1:Many via [ID#] to CrtTable CrtTable is linked 1:Many via [Court ID#] to CrtSubTab
I need to find out the most recent court date [Pending Court Date] from the CrtSubTab for each [ID#] depending on the quarter (which is a field [Quarter] in the CrtTable). I will set [Quarter] criteria to pull from a choice selected on a seperate form prior to running the query. In addition, I'd like to have the dates that are pulled fall within in a specific date set, which I can also input on the same form that restricts the quarter. This I know is a simple Iif statement using < & >. But - will that impact my ability to use Max through SQL? I have seen several posts referencing the need to use two queries.
Hello people - I am building an APPEND and DELETE Query which deletes STUDENTS in my Camera Loans database who have not borrowed a camera in more than two years.
In the query structure, under DATE_BORROWED, I put the expression <=Date()-730 (where 730 = 365 days x 2.)
However, upon running the query it gave back to me the earliest loan date of the student, (so their first loan date and details basically)
It ignores the more recent loans, so deleting this appended record would be a mistake.
Now I need an expression in a duplicated DATE_BORROWED field in the query structure that picks out the most RECENT date out of them all, the other field running the check on this most recent date to see if it is older than two years.
Surely there is some code or expression that pulls the most recent date out only of a whole series in a record? Or a criteria is performed on the rmost ecent loan only?
I have a parent table [Case] and a child table [Action], in a one-to-many [Access 2003].
The parent has an open date and a closed date.
The child has a received date and a completed date. The child may contain more than 1 record that matches the parent.
Date fields for activities that have not yet happened are blank.
A typical example might be one parent and two child entries for a total of six dates fields.
I am after only a [single] most-recent action date of the six [there could be a tie for that most recent date, and then there would be two records returned in the result].
I am working for a table that includes a list of every parent record with the name and date of the most recent, or latest activity date.
The database I am working with contains several different tables and a variety of information. I need to create a query that accesses information from two different tables. Though the tables contain other fields, the fields I am most interested in are:
Table 1: Protocol Information "Protocol ID", "Title", "Expiration Date"
Table 2: Regulatory Submission "Protocol ID", "Description of Submission", "Submitted By", "Date of Submission".
The way the data is stored, each protocol has a Protocol ID, and there is only one record per protocol in the "Protocol Information" table.
However, each time these protocols are submitted to our review board, a log is created in the "Regulatory Submissions" table.
I need to generate a query that pulls only the most recent submission date, so that the query output would look like this:
"Protocol ID", "Title", "Description of Submission", "Submitted By", "Date of Submission" (Where this is the most recent one), "Expiration Date"
From other forums and posts, I tried to create an SQL aggregate function, using Max or Last to get the most recent date. I was successful, but only if the query contained just the "Protocol ID", "Date Submitted", and "Description of Submission" fields. Adding any more, or creating a query to use the outputted data didn't work (it could be that my second query was not written correctly.) I am very novice at creating complex queries, and at SQL.
One additional complication: There are two values in the "Description of Submission" field of the "Regulatory Submissions" table that I am not interested in. They are "Adverse event" and "AE Summary Log". I can successfully filter them out using a criteria expression, but integrating all of these pieces has not been easy (or possible, yet).
I'm out of ideas. This is really complicated, and I apologize. Any assistance would be greatly appreciated.
Hello, I'm working with SQL and databases in general for the first time, and was wondering: how would I select just the most recent entry for each device? my data looks [roughly] like this:
I'm trying to create a report for how many "nasty grams" (rejection notices) my company has sent to people who keep sending in paper forms when they are supposed to file electronically.Every letter that goes out has information recorded based on whatever they sent to us - so the only remotely reliable way to count how many each person received is by the address on the envelope (people use different names, different business names, use different telephone numbers on the forms, etc).
I just built several queries that feed into a report that gets sent to my boss on a monthly basis to show the people who've sent in more than one paper form and have received our rejection notices more than once.I'm not the greatest at SQL, but I've been trying to find a way to use DISTINCT Addresses, leave all other fields the same (not DISTINCT), to:
1. Only return people who have received 2 or more letters
2. If at least one of the letters was sent more than 90 days ago AND If at least one of the letters was within the last 90 days -If at least one was within the last 90 days, only display the most recent send date of the letter (lots of people get back-to-back letters).
3. Display their names, addresses, telephone numbers, the date of the most recent letter sent, count of the total letters ever sent to that person. (the report will already do this, just need Max date)
My first query counts the number of times each address appears in the main table and simply only has [Address] and [CountofAddress]
My second query has the [Name], the [LetterDated] >=Now()-90, and the qryCountofAddress is linked to the main table by [Address], using [Countof Address] >=2...I have tried Selecting Unique Values in the Properties tab. Yes, I have tried INNER JOIN (but can't get the rest of my fields to display once I make addresses distinct).
I am having trouble getting a query or report to show only the most recent data.
We have salesmen that use a handheld data collector scanners to count inventory in stores. The scanner data is imported to a Access table. Each record line is one scanned item. I have a query with totals that counts the records and gives me a total count of each item at the store on that date.
I then need to filter the data to only show the most recent date. Using Max Date I get the most recent date but the count fields are showing totals for all dates. I am also getting the unique item from the earlier date in this query which I do not want.
Here is my data table: Inventory Scans from stores.
Scan Date Item Scanned location
1/1/2014 item123 Store ABC
1/1/2014 item123 Store ABC
......
Here is my Query with Totals that counts the item records:
Scan Date Item Scanned location (Item Scanned) count
1/1/2014 item123 Store ABC 2
1/1/2014 item 456 Store ABC 3
1/1/2014 item 789 Store ABC 1
2/1/2014 item123 Store ABC 2
2/1/2014 item 456 Store ABC 1
This is what I am trying to get - only the most recent date of counted items:
Scan Date Item Scanned location (Item Scanned) count
Using a single-step Access query, I need to retrieve, for each PatientID, the most recent LabDate and Result *of a given LabID*. Thus, from the example dataset above, the desired output for LabID 55 is:
I have searched this forum and others, but have not found an answer that I can directly tanslate to my situation. I have successfully written queries (with included subqueries) that retrieve the most recent of all the Labs, but have failed at obtaining a result dataset that contains only the records within a specified LabID.
For example, the query below fails because whenever the most recent of *all* the LabDates is not the same as the most recent of *the LabDates with a LabID=55*, the correct record is not included in the results. In the example dataset above, 0 records are returned.
SELECT a.PatientID, a.LabID, a.LabDate, a.Result FROM Labs AS a INNER JOIN (SELECT PatientID, MAX(LabDate) AS MaxLabDate FROM Labs GROUP BY PatientID) AS b ON (a.PatientID = b.PatientID) AND (a.LabDate = b.MaxLabDate) WHERE (((a.LabID)=55));