Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Need SQL to find LATEST child record
Message
De
15/04/2003 11:35:26
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
15/04/2003 11:28:55
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:
00777809
Vues:
15
>Cetin,
>I tried it. I did not get ANY recs so I changed the INNER JOIN to be ON a.cid = b.cinmates_id because I believe that is what you meant. Now, I get ALL the OPEN records from ACCT_EVENTS. Again, (perhaps I am not stating it correctly), I need all recs from INMATES where LASTEST rec in ACCT_EVENTS status = OPEN.
>
>select a.cid, a.cinmate_number, ;
> b.cinmates_id, b.ttxndatetm, b.txnstatus ;
> from INMATES a ;
>   inner join ACCT_EVENTS b ;
>        on a.cid = b.cinmates_id ;
> where ttoc(b.ttxndatetm,1) = ;
>   (select max(ttoc(ttxndatetm,1)) from ACCT_EVENTS c ;
>     where b.cid = c.cid and c.txnStatus= 'OPEN')
>
>Thanks,
>John

Oh I missed that :) You then need to change cid in 2nd where too :
select a.cid, a.cinmate_number, ;
 b.cinmates_id, b.ttxndatetm, b.txnstatus ;
 from INMATES a ;
   inner join ACCT_EVENTS b ;
        on a.cid = b.cinmates_id ;
 where ttoc(b.ttxndatetm,1) = ;
   (select max(ttoc(ttxndatetm,1)) from ACCT_EVENTS c ;
     where b.cinmates_id = c.cinmates_id and c.txnStatus= 'OPEN')
If you mean to return only one record remove 'b.cinmates_id = c.cinmates_id and'
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform