Return top 2 records on an inner join table

D

dbadmin

Please help. I am trying to build a query to return the top top remarks from
an inner join table within the following query:

SELECT tblMASTERINFO.[Work Request #], tblMASTERINFO.[Test Name],
tblMASTERINFO.SCHEDULEDSTARTCURRENT, tblMASTERINFO.SCHEDULEDENDCURRENT,
tblMASTERINFO.ActStart, tblMASTERINFO.ActEnd, tblMASTERINFO.TESTPHASE,
tblRemarks.Remark
FROM tblMASTERINFO INNER JOIN tblRemarks ON tblMASTERINFO.TMSSUBTESTNUMBER =
tblRemarks.TMSSUBTESTNUMBER
WHERE (((tblMASTERINFO.TESTPHASE) Like "Active" Or
(tblMASTERINFO.TESTPHASE)="Planning" Or
(tblMASTERINFO.TESTPHASE)="Reporting") AND ((tblMASTERINFO.TMSSUBTESTNUMBER)
Like "06-*"))
ORDER BY tblMASTERINFO.[Test Name];

I know I need to use "Top 2", but where and how do I keep the other fields
from duplicating, when I use the query for the report?
 
K

KARL DEWEY

Edit SQL like this --
SELECT TOP 2 tblMASTERINFO.[Work Request #], tblMASTERINFO.[Test Name],

You have ORDER BY tblMASTERINFO.[Test Name]; so the two you get will be
those lowest in the alphabet. You may get more if the second and third are
identical.

This is not understood.



dbadmin said:
Please help. I am trying to build a query to return the top top remarks from
an inner join table within the following query:

SELECT tblMASTERINFO.[Work Request #], tblMASTERINFO.[Test Name],
tblMASTERINFO.SCHEDULEDSTARTCURRENT, tblMASTERINFO.SCHEDULEDENDCURRENT,
tblMASTERINFO.ActStart, tblMASTERINFO.ActEnd, tblMASTERINFO.TESTPHASE,
tblRemarks.Remark
FROM tblMASTERINFO INNER JOIN tblRemarks ON tblMASTERINFO.TMSSUBTESTNUMBER =
tblRemarks.TMSSUBTESTNUMBER
WHERE (((tblMASTERINFO.TESTPHASE) Like "Active" Or
(tblMASTERINFO.TESTPHASE)="Planning" Or
(tblMASTERINFO.TESTPHASE)="Reporting") AND ((tblMASTERINFO.TMSSUBTESTNUMBER)
Like "06-*"))
ORDER BY tblMASTERINFO.[Test Name];

I know I need to use "Top 2", but where and how do I keep the other fields
from duplicating, when I use the query for the report?
 

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

Top