Hi
I have two table: header and history. The header record contains Primary Key, PNum and a Status column that can be either 'Open', 'In Progress' or 'Closed'. The header record can only move statuses in that order, ie. from 'Open' to 'In Progress' to finally 'Closed'.
In the History table, there is a foreign key PNum from the header table. Each header row can have one or many (up to 3) history rows.
For example, if my header row has been updated with status twice from 'Open' (first update) to 'In Progress' (second update), I will have two records in the history table (PNum1, Open and PNum1, In Progress).
I would like to find the latest (or the last) history row for each header row and compare the statuses. How would I achieve this using SQL on Oracle 8i?
(I hope I have clearly explained what I want. If not then please let me know and I will provide more clarification.)
Thanks
Chadi
I have two table: header and history. The header record contains Primary Key, PNum and a Status column that can be either 'Open', 'In Progress' or 'Closed'. The header record can only move statuses in that order, ie. from 'Open' to 'In Progress' to finally 'Closed'.
In the History table, there is a foreign key PNum from the header table. Each header row can have one or many (up to 3) history rows.
For example, if my header row has been updated with status twice from 'Open' (first update) to 'In Progress' (second update), I will have two records in the history table (PNum1, Open and PNum1, In Progress).
I would like to find the latest (or the last) history row for each header row and compare the statuses. How would I achieve this using SQL on Oracle 8i?
(I hope I have clearly explained what I want. If not then please let me know and I will provide more clarification.)
Thanks
Chadi