Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Finding Last 4 occurrences
I think this will get it, assuming your table is t1
select work_order, part_number
from t1 a
where work_order in
(select work_order
from t1
where part_number = a.part_number
and rownum <= 4
)
James Reinardy wrote in message <383af2e3$0$96890_at_news.execpc.com>...
>Hello all,
>
>I am having a mental block trying to get a query to work. I have work
>orders for part numbers, and I want to get up to the last four work
>orders for each part number.
>
>As an example, if I have the following data
>
>Order Part
>1 A
>2 A
>3 A
>4 A
>5 A
>6 A
>7 B
>8 B
>9 B
>
>
>What I would like returned is:
>
>1 A
>2 A
>3 A
>4 A
>7 B
>8 B
>9 B
>
>It seems like there should be a way, but I can't come up with it.
>
>Thanks for any help you can provide.
>
>Jim Reinardy,
>Orion Corporation
Received on Tue Nov 23 1999 - 20:38:53 CST