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!

Problems with a query

Status
Not open for further replies.

rafal444

Programmer
Aug 11, 2006
74
US
The query below is droping many statements, It only shows statements for 6/30/2006, which is the latest statement out of all movies.

I want to show the movie and the latest statement for that particular movie. This is the query I have:

SELECT A.*
FROM [QryReportBase_CalculatedAll Step 4] AS A
WHERE (((A.StatementDate)=(Select Max([StatementDate]) from [QryReportBase_CalculatedAll Step 4] as B Where B.FilmID=A.FilmID)))
ORDER BY A.Film;

 
Something like this ?
SELECT A.*
FROM [QryReportBase_CalculatedAll Step 4] AS A INNER JOIN (
SELECT FilmID, Max(StatementDate) AS LastStatement FROM [QryReportBase_CalculatedAll Step 4] GROUP BY FilmID
) AS B ON A.FilmID = B.FilmID AND A.StatementDate = B.LastStatement
ORDER BY A.Film

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top