top 3 from subtable

G

Guest

I have (main table), tblAction with actionID, title, name. Another table
(child table), tblRemarks with remID, actionID, remDate, Remark

I would like create query/report to show all record from tblAction but show
only the top 3 remDate on each group actionID from the tblRemarks.

Thank you in advance.

eg. actionID title RemDate Remarks
1 www 1/31/07 remwww
1 xxx 3/2/07 remxxx
1 yyy 4/4/07 remyyy

2 zzz 2/4/07 remzzz
2 aaa 4/31/07 remaaa
2 bbb 5/2/07 rembbb
2 ccc 6/4/07 remccc


Results should be:
eg. actionID title RemDate Remarks
1 yyy 4/4/07 remwww
1 xxx 3/2/07 remxxx
1 www 1/31/07 remyyy

2 ccc 6/4/07 remzzz
2 bbb 5/2/07 remaaa
2 aaa 4/31/07 rembbb
 
A

Allen Browne

Create a query using tblRemarks, sorted by remDate Descending (i.e. most
recent first.) In the properties box in query design, set the query's Top
Values to 3.

Create a report bound to tblAction, with a subreport bound to the query.

If you want to do it in a query instead of a report, here's how:
http://allenbrowne.com/subquery-01.html#TopN
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Help with Query?? 1
update query 5
Serial No for Unique Value 1
Adding lines together to create one line 4
Any way to shift data axes? 2
Access query 5
Delete Related records 2
Top 3 for each product 2

Top