Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query Based on Last Date

Status
Not open for further replies.

MooseMan

IS-IT--Management
Aug 25, 2001
63
0
0
CA
I have a table called tblDefaults which contains monthly default reports for 50 different administrators. I have been trying to build a query based on three fields in that table. AdministratorID, DefaultAmount, and ReportingMonth.

My problem is that the query which will show the default amount by administrator has to be based on the most recent default report for that administrator. ReportingMonth is a date field indicating the reporting month, but when I use Last or Max in the query design I get multiple records for a number of AdministratorID's.

If the query were to work properly I should get one record for each AdministratorID and that record being the most recent entered into the Table.

Any help would be greatly appreciated.
 
I think this may be close to what you want

select AdministratorID, DefaultAmount, reportingmonth
from tbl where tbl.reportingmonth =(select Max(reportingmonth from tbl as a where a.AdministratorID = tbl.AdministratorID)as maxmonth

it uses a subquery and aliases the tbl



 
How do you calculate the total number of orders by one customer and have the specific dates in which they purchased them on one database?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top