Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Possible Use of a Cursor
Am 22 Feb 2005 07:42:04 -0800 schrieb Paul Izzo <paul.izzo_at_mosca-ag.com>:
> I have a complex query that I hope I can explain it well enough for
> everyone to understand.
>
> I have a table that contains information for work instructions.
> Contained in the table are "MACHINE_PROC" these are groupings of
> machining processes (milling,drilling etc). Contained also in the table
> are "INSTRUCTION" that are a grouping of machining processes in a
> particular order. In order to organize the order "MACHINE_PROC" are
> made they become a "POSITION_NR".
> "INSTRUCTION" can have any number of "POSITION_NR" and
> "MACHINE_PROC". "POSITION_NR" are always acending meaning that the
> smallest number is at the begining of a instruction and the larger a
> number towards the end.
>
> The problem that I have is that I want to look for a given set of
> machining processes (MACHINE_PROC) from groups 3500, 3400 and 3430 in
> the first position of a given INSTRUCTION. The problem is that the
> first step of a INSTRUCTION doesn't always have the same number.
What about
select t_outer.*
from table t_outer
where
t_outer.POSITION_NR =
(select min(t_inner.POSITION_NR) from table t_inner where t_inner.INSTRUCTION_NR = t_outer.INSTRUCTIOn_NR and t_inner.MACHINE_PROC = t_outer.MACHINE_PROC)