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 to find most recent date.

Status
Not open for further replies.

jalge2

Technical User
Feb 5, 2003
105
0
0
US
I have a form on a database that keeps track of work orders. Once a week our tech comes in to fix our Scan Guns and we enter the fix date on the work order. Every Monday my boss wants to run a query to see how many guns were fixed on the most recent date. The tech doesn't come in on the same day.

Is there a way that I can build a query to just find the most recent date and pull that information?

Thanks for all the help.

Jason Alge
Jason.M.Alge@lowes.com

'There are three kinds of people: Those who can count and those who can't'
 
First you find the most recent date.

Code:
SELECT MAX(date_of_service) FROM WorkOrders

Then count the number or find the number of scan-guns repaired on that date, depending on whether there is one work order for each repair or a work order shows the number repaired.
Code:
SELECT COUNT(*) FROM WorkOrders
WHERE date_of_service = (SELECT MAX(date_of_service) FROM WorkOrders)

Code:
SELECT number_repaired FROM WorkOrders
WHERE date_of_service = (SELECT MAX(date_of_service) FROM WorkOrders)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top