|
-
order_id, orderd_date,order revision
======================================
55761 ,'10-MAR-05',1
55761,'11-MAR-05',2
55761,'12-MAR-05',3
55762 ,'12-MAR-05',1
55762,'13-MAR-05',2
55762,'14-MAR-05',3
55763 ,'15-MAR-05',1
55763,'15-MAR-05',2
55763,'16-MAR-05',3
55763,'17-MAR-05',4
====================================
i am looking for results like this
order_id, orderd_date,order revision
55761,'11-MAR-05',2
55762,'13-MAR-05',2
55763,'16-MAR-05',3
======================================
when i run thsi query for one job i got results
SELECT *
FROM (
SELECT order_id, ordered_date,orderrevision,
RANK() OVER (ORDER BY ordered_date,orderrevision DESC) ORANK
FROM orders where order_id =55761)
WHERE orank = 2;
order_id, orderd_date,order revision
55761,'11-MAR-05',2
========================================
but when i do this
SELECT *
FROM (
SELECT order_id, ordered_date,
RANK() OVER (ORDER BY ordered_date,orderrevision DESC) ORANK
FROM orders )
WHERE orank = 2;
thsi doesn't return for each instead returns last but last row in table
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|