Existing workflows with status?
> Existing workflows = what workflows are available in the system. There's no status for this.
> Currently running workflows = workflows that are running right now. They usually have status like active, blocked etc.
> Last statistic entry of all workflows = last run / active run of all specified workflows. Might be active, might be ENDED_OK, ENDED_CANCEL etc. and might also involve objects that have been deleted in the meantime. This all depends on the requirement and will impact the SQL query.
... so what exactly do you want to achive?
Select all OH_OType = 'JOBP' with OH_Client = 5 & OH_DeleteFlag = 0 from OH table. This lists you all workflows of your client and should equal the number you find in the object search. Left join this result using client & name attribute the AH table and pick the latest entry only.
If you go for AH only with an timestamp4 condition you won't see workflows with no ended execution in that timerange.
Retrieving data ...