way to subquery for next record in query?

A

ArielZusya

I've got a query (qryMaingroup) that looks at a table (tblMain) and displays
all the records in tblMain with a seat number less than a particular value.
I'd like to query that query to find the first record that has a seat number
which adding 1 would mean that the next record in the original query is not
equal. In other words if the first query returns all those in tblMain with
tblMain.Seat less than 13, the second query returns the lowest Seat value
from the first query where tblMain.Seat + 1 < tblMain.Seat from the next
lowest value in that first query. I think ultimately I'm looking for a way
to return the record that appears next in the query of tblMain. Is there a
way to do that? Thanks!
 
A

ArielZusya

Nevermind... figured it out on my own. I realized I was calling tblMain.Seat
from tblSeat.Seat so I did a query for the unmatch and bingo! I'm loving
access today! In case anyone else reads this and wants to know exactly what
I did:

SELECT tblMain.ID_Main, tblMain.Seat
FROM tblMain LEFT JOIN tblSeat ON tblMain.[Seat] = tblSeat.[Seat]
WHERE (((tblSeat.Seat) Is Null) AND ((tblMain.RefNum)="205CBV609"));

to return the seat numbers for the empty seats in tblMain for all records
with the specified RefNum. I'm so happy!
 

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