Task Table | |||
---|---|---|---|
Server ID | Action | Task ID | Status |
123 | 43 | 1 | completed |
123 | 43 | 3 | completed |
123 | 43 | 2 | completed |
123 | 43 | 4 | active |
123 | 43 | 5 | active |
123 | 45 | 1 | active |
123 | 45 | 4 | active |
123 | 45 | 3 | active |
123 | 45 | 2 | active |
123 | 45 | 5 | active |
234 | 43 | 5 | active |
234 | 43 | 3 | active |
234 | 43 | 4 | completed |
234 | 43 | 2 | completed |
234 | 43 | 1 | completed |
Task Template | |||
TaskID | TaskPredecessor | ||
2 | 1 | ||
3 | 2 | ||
4 | 2 | ||
5 | 4 | ||
6 | 5 | ||
Output | |||
Server ID | Action | Task ID | Status |
123 | 43 | 1 | completed |
123 | 43 | 3 | completed |
123 | 43 | 2 | completed |
123 | 43 | 4 | active |
123 | 45 | 1 | active |
234 | 43 | 3 | active |
234 | 43 | 4 | completed |
234 | 43 | 2 | completed |
234 | 43 | 1 | completed |
Preface: The query should look at the combination of the ServerID and Action ID pick up the task ID and check if it has a predecessor. If it has a predecessor then check the server action combination with that predecessor ID with status completed or active. If completed then check next.
Output: The output should print the Server action combination along with task ID and status. Constraint: it should print all the completed task and should stop printing at the latest active task.
ASK: Cant seem to get my head around it. Please post a sample query. Note: No use of cursors.