How about some sample data to help us out?
Also, a plain English description of what you're trying to accomplish would help a lot more than a query that doesn't work
And in addition to what Greg has said I would suggest to read Re: 2. How do I ask a question on the forums?
Your question is missing:
- sample data
- database version
- logic you want to achieve
- expected output for the sample data provided.
sample data is following, it's taking a little bit of time though..
maybe someone is a genius and can help me without?
This is what I am trying to change, for perfomance reasons:
FOR OXL IN ( SELECT Order_ID, Machine_ID, Best_Order_ID, Order_Version FROM EXPORT_LOCAL_ORDER ) LOOP select id into v_oid from (select id from orders where finished <= (select started from orders where id = OXL.Order_ID) and machine_id = OXL.Machine_ID order by finished desc) where rownum=1; END LOOP;
English, not code . explain what you are trying to do "in plain English".
1 person found this helpful
You can't reference a column from the outer query like that, but you could try this:
FROM (SELECT oxl.order_id,
FROM export_local_order oxl,
WHERE o1.finished <= (SELECT o2.started
FROM orders o2
WHERE o2.id = oxl.order_id)
AND o1.machine_id = oxl.machine_id
ORDER BY o1.finished DESC) a
WHERE a.rownum = 1
It's hard to tell if it will work without any test data