Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Need SQL to find LATEST child record
Message
 
À
15/04/2003 15:28:00
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00777700
Message ID:
00778001
Vues:
28
>OK Cetin,
>First, let me tell you how much I appreciate the assistance. This SQL is above my pay grade.
>
>We are soooo close. Obviously I have not been clear enough.
>
>You are getting the latest OPEN transaction per inmate. That's helpful but not exactly what I need.
>
>Inmate 0012345 should not show in the cursor. Why? His latest transaction is a "CLOSED". Only the inmates where the latest transaction is an "OPEN" should show in the cursor. So what I am after is a list of inmates that are currently OPEN.
>
>Having said all that, I could be doing something wrong. Please correct me if I am.
>Thanks,
>John

John,

How about this:
SELECT cInmate_Number, tTxnDateTm, TxnStatus ;
  FROM INMATES im ;
    LEFT JOIN ACCT_EVENTS ae ;
      ON im.cID = ae.cInmates_ID ;
  WHERE tTxnDateTm IN (SELECT MAX(tTxnDateTm) FROM ACCT_EVENTS GROUP BY cInmates_ID) ;
    AND TxnStatus = 'OPEN'
Then, just substitute a view parameter variable for 'OPEN' and I believe you will have what you are looking for.
_________________________________
There are 2 types of people in the world:
    Those who need closure
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform