I've the 2 following tables:
|_________________WORKFLOW__________________||___________STEP___________|
| ID_WORKFLOW | ID_STEP | ID_OBJECT || ID_STEP | CODE | LEVEL |
|-------------|---------|-------------------||---------|--------|-------|
| 100 | 1 | BUSNIESS_OBJECT_1 || 1 | STEP_1 | 10 |
| 101 | 2 | BUSNIESS_OBJECT_1 || 2 | STEP_2 | 20 |
| 102 | 3 | BUSNIESS_OBJECT_1 || 3 | STEP_3 | 30 |
| 103 | 4 | BUSNIESS_OBJECT_1 || 4 | STEP_4 | 40 |
| 104 | 5 | BUSNIESS_OBJECT_1 || 5 | STEP_5 | 50 |
| 105 | 1 | BUSNIESS_OBJECT_2 |----------------------------
| 106 | 2 | BUSNIESS_OBJECT_2 |
| 107 | 3 | BUSNIESS_OBJECT_2 |
---------------------------------------------
I want to query WORKFLOW
table filtering on STEP->CODE column and having the last STEP->LEVEL.
For example, I'd like to get from workflow table workflows where STEP->CODE = 'STEP_3'. In the result, I expect ID_WORKFLOW = 107. But not ID_WORKFLOW = 102. Because this one has an advanced step of 4 (ID_WORKFLOW = 103) It's STEP->LEVEL is greater than 40>30.
I don't know if it's possible to get the result using a simple sql query with some joins or if I need to definitely use a cursor for this.
Many thanks for your advices in advance,
1条答案
按热度按时间z9ju0rcb1#
Assuming I understand your question, that you are looking for business objects at a particular step in the workflow, here is something you can try:
RETURNS
NOTES
CODE
values are in sync with theirID_STEP
values (e.g., id_step: 1 = code: Step 1, etc.).id_object
.UPDATE
To filter based on a steps level instead...
RETURNS