Examples: SQL queries
Use this reference to learn sample SQL queries.
Example 1: Report on workflow definitions and runs
Note that for a workflow run, originalworkflowid is the ID of the corresponding workflow definition. For a workflow definition, originalworkflowid is null.
Query results:
Example 2: Report on recently-updated tasks in workflow definitions
Note that if a task is part of a workflow run, originalworkflowid is the ID of the corresponding workflow definition. Otherwise, originalworkflowid is null. Therefore, t.originalworkflowid IS NULL ensures that the report excludes tasks that are part of workflow runs.
Query results:
Example 3: Report on failed API calls for a particular workflow
Notes:
a.originalworkflowid = 298specifies the ID of a workflow definition.a.taskidis the ID of a task that is part of a workflow run, so tasktis part of a workflow run.- Since
tis part of a workflow run,t.workflowidis the ID of the workflow run andt.originaltaskidis the ID of the task in the corresponding workflow definition.
Query results:
Example 4: Report on the downstream tasks of a particular task
Notes:
l.sourcetaskid = 397specifies the ID of a task that is part of a workflow definition.
Query results:
Example 5: Report on the number of Email task runs per day
Notes:
emailcountis the number of times the Email task was used (per day) across all workflow runs.
Query results:
Example 6: Report on workflow task usage beyond the automatic cleanup period
Workflow and workflow task usage that are beyond the automatic cleanup period cannot be retrieved using the normal SQL queries. But you can use the above example to retrieve the usage data beyond the cleanup period by month. The DATE_TRUNC('month', createddate) function groups data by month. Alternatively, you can use DATE_TRUNC('year', createddate) to retrieve data by year.
You can modify the fields in SUM (...) AS total_tasks to retrieve different information.