Capturing most recent zero date

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a table that is contains a/r balances and I want to get the most
recent date that the balance was 0. Currently there are 65 days worth of
data. I would also want to get the next date that did not have a 0 balance.
 
PegGall said:
I have a table that is contains a/r balances and I want to get the most
recent date that the balance was 0. Currently there are 65 days worth of
data. I would also want to get the next date that did not have a 0 balance.


SELECT TOP 2 T.datefield, T.balance
FROM table As T
WHERE T.datefield >= (SELECT Max(X.datefield)
FROM table As X
WHERE X.balance = 0)
ORDER BY T.datefield ASC
 
Back
Top