Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: Data with Max Qty and Date ?

Re: Data with Max Qty and Date ?

From: Michel Cadot <micadot{at}altern{dot}org>
Date: Wed, 28 Jul 2004 20:41:32 +0200
Message-ID: <4107f2e7$0$12491$626a14ce@news.free.fr>

"captain" <captain_2010_at_yahoo.com> a écrit dans le message de news:27aae5ab.0407272342.4d8e5bb5_at_posting.google.com...
> hi all,
>
> I am really do not know how to get this. Tried all types of queries.
> The requirement is as below
>
> itemid maxqty Mdate (date is when the max qty went out)
> 001 5 5/1/2004
> 002 2 5/10/2004
>
> The actual table has all transaction data as below.
> itemid qty date
> 001 5 5/1/2004
> 001 3 5/2/2004
> 001 3 5/3/2004
> 001 2 5/4/2004
> 002 0 5/1/2004
> .....
> 002 2 5/10/2004
>
> one query is
> select itemid,max(qty) from mTran
>
> with the above require which date it occurred.
>
> Please help
>
> Cap2010

Try this:

select itemid, quantity, mdate
from (select itemid, qty, mdate,

    rank() over (partition by itemid order by qty desc) rn    from mtran)
where rn=1
/

--
Regards
Michel Cadot
Received on Wed Jul 28 2004 - 13:41:32 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US