Hi there.
I come predominantly from a SQL Server background. What I am currently trying to do I would easily accomplish with a quick Temp Table & a Cursor.
I am on an Oracle 8i installation. As such, I understand that Temp Tables are taboo, a point I am happy to accept. Unfortunately, that causes me issues, in that I don't currently know how to resolve my issue without them.
So, here's the problem:
I return the latest Work_Orders from a number of tables. Each of the WO's is attached to a piece of Equipment (Equip_No).
On each returned record, I need to also include the last (MAX(Closed_Dt)) WO for this Equip_No.
I tried the above with an InLine View, but hit a snag when I tried to access one InLine View from within another.
My logic tells me it can't work, due to the fact that I need to return the MAX for each & every Equip_No. Any & all assistance at this point is exceedingly well received.
Regards,
Peter.
I come predominantly from a SQL Server background. What I am currently trying to do I would easily accomplish with a quick Temp Table & a Cursor.
I am on an Oracle 8i installation. As such, I understand that Temp Tables are taboo, a point I am happy to accept. Unfortunately, that causes me issues, in that I don't currently know how to resolve my issue without them.
So, here's the problem:
I return the latest Work_Orders from a number of tables. Each of the WO's is attached to a piece of Equipment (Equip_No).
On each returned record, I need to also include the last (MAX(Closed_Dt)) WO for this Equip_No.
I tried the above with an InLine View, but hit a snag when I tried to access one InLine View from within another.
My logic tells me it can't work, due to the fact that I need to return the MAX for each & every Equip_No. Any & all assistance at this point is exceedingly well received.
Regards,
Peter.
Code:
SELECT
WO_Orig.*,
WO_Sched.LastSchedDate
FROM
(
SELECT
MSF600.equip_location,
MSF600.item_name_1,
MSF600.item_name_2,
MSF620.closed_dt,
MSF620.comp_code,
MSF620.comp_mod_code,
MSF620.dstrct_code,
MSF620.equip_no,
MSF620.plan_str_date,
MSF620.raised_date,
MSF620.wo_desc,
MSF620.wo_status_m,
MSF620.work_order
FROM
MSF600 MSF600,
MSF620 MSF620
WHERE
msf620.equip_no = msf600.equip_no
AND msf600.equip_classifx5 = 'Y'
) WO_Orig,
(
SELECT
MAX(MSF620.Raised_Date) LastSchedDate
FROM
MSF620,
WO_Orig
WHERE
MSF620.Equip_No = WO_Orig.Equip_No
AND MSF620.Work_Order < WO_Orig.Work_Order
AND MSF620.Maint_Sch_Task <> ' '
) WO_Sched
WHERE
MSF620.Equip_No = WO_Orig.Equip_No AND
MSF620.Work_Order < WO_Orig.Work_Order AND
MSF620.Maint_Sch_Task <> ' '