Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: BEGINNERS SQL QUESTION
How about
select tranuid, tranname, entrydate, status
from mytran my, mytranstatus stat
where my.tranuid = stat.tranuid
and entrydate = (select max(entrydate) from mytranstatus stat2
where stat2.tranuid = my.tranuid)
Haven't tried this, but I think the max() function works on DATEs
Christian
davout wrote:
>
> I have two tables....
>
> MyTran
> ---------------
> TranUID INTEGER
> TranName VARCHAR
>
> MyTranStatus
> ------------------------
> TranUID INTEGER
> EntryDate DATE
> Status INTEGER
>
> The data is something like....
>
> MyTran
> --------------
> TranUID TranName
> 1 Trans#1
> 2 Trans#2
>
> MyTranStatus
> --------------------
> TranUID EntryDate Status
> 1 23/1/99 6
> 1 2/2/99 7
> 1 10/2/99 5
> 2 31/1/99 6
> 2 28/2/99 4
>
> How can I create a query whereby I can get all the records back from
> 'MyTran' with the most recent entry from the related MyTranStatus table?
> Like...
>
> 1 Trans#1 10/2/99 5
> 2 Trans#2 28/2/99 4
>
> Any ideas?
Received on Tue Mar 09 1999 - 23:42:13 CST
![]() |
![]() |