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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Return only Last Dated Entry

Status
Not open for further replies.

TamaraR

Technical User
Jan 7, 2002
6
0
0
CA
I have built a database that holds information on different wells. I have all the wells with their information in one table and another table holds each sampling event for the wells. (The sampling is donequarterly but over a three week span. Each well record is linked to many records containing sampling information. I would like to make my query for a report return only the information for the last date that the wells were sampled. Then I can print reports with only the most recent information.

Any help on this is appreciated.

Tamara
 
The general syntax for doing such a query is as follows.

Select t.* From SampleTable As t
Where SampleDate =
(Select Max(SampleDate)
From SampleTable
Where WellID=t.WellID)
Terry L. Broadbent - DBA
Computing Links:
faq183-874 contains "Suggestions for Getting Quick and Appropriate Answers" to your questions in the SQL Server forum. Many of the ideas apply to all forums.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top