View Single Post

   
  #1 (permalink)  
Old 02-28-2008, 10:27 AM
Anony
 
Posts: n/a
Default Returning last met record only!

Hello there, I am trying to return all accounts whos *LATEST*
arrangement on that account was NOT met, ie Arrangement_Met=0

here are the tables in question

TABLE Accounts
(
Account_ID
Account_Number
.... <more fields>
}


TABLE Arrangement
{
Arrangement_ID
Account_ID
Arrangement_Met
Arrangement_Date
Arrangement_Time
.... <more fields>
FOREIGN KEY (Account_ID)
}

I can return returns all accounts who have an arrangement that is NOT
met no
problem *but* if the last arrangement is met, and they have older
arrangements that
are not met it will still return that account... what I need is some
nifty sql that will
only return accounts whos most recently created arrangment (ordered by
date and
time) has not been met, ie Arrangement.Arrangement_Met=0 for all
accounts ...

This returns all accounts who have an arrangement that has not been
met

Select * from Accounts
left outer join Arrangement on (Accounts.Account_ID =
Arrangement.Account_ID) WHERE Arrangement.Arrangement_Met=0

what I need is some nifty sql that will only return accounts whos
**last / most recently added** arrangment has *not* been met, ie
Arrangement.Arrangement_Met=0,
regardless of older arrangements! ...

Any help whatso ever anyone can give me would be amazing! Thanks in
advance for
taking the time to look at my problem...
Reply With Quote