"Mark" <mm*****@earthlink.net> wrote in
news:%W***************@newsread3.news.atl.earthlin k.net:
"David W. Fenton" <dX********@bway.net.invalid> wrote in message
news:Xn**********************************@24.168.1 28.86... "CDB" <al***@delete.wave.co.nz> wrote in
news:c5**********@news.wave.co.nz:
> This is another approach:
>
> SELECT TOP 1 *
> FROM [SELECT TOP 2 SomeTable.ReturnDate As RDt
> FROM SomeTable
> ORDER BY SomeTable.ReturnDate DESC]. As A
> ORDER BY A.RDt;
>
> The sub-query notation is for A97/Jet, but also works in
> A2K/Jet.
What about an non-equi join, on B.ReturnDate < A.ReturnDate? Then
you can apply criteria easily (even with a paramater), which you
can't do with the "virtual" table approach above.
Could you show what you mean.
Well, if you've got a join:
SELECT TOP 1 A.ReturnDate As Date1, B.ReturnDate As Date2
FROM SomeTable AS A INNER JOIN SomeTable AS B On A.ReturnDate <
B.ReturnDate WHERE A.ReturnDate=#1/1/2004#
ORDER BY A.ReturnDate, B.ReturnDate;
Something like that.
The method for doing this is to create the join with the QBE, then
in SQL view, change the "=" to < or > (depending on which you want.
You then won't be able to view the query in the QBE, but it will do
what you want.
The result will be a single row with your the date you filtered for
in the WHERE clause (which could then be parameterized), and the
second column being the next date greater than the date you filtered
on.
--
David W. Fenton
http://www.bway.net/~dfenton
dfenton at bway dot net
http://www.bway.net/~dfassoc