Skip to content

Instantly share code, notes, and snippets.

@dorkness-io
Last active March 19, 2020 18:40
Show Gist options
  • Save dorkness-io/5fb35a0e0d9936f0019554d84ec9a62a to your computer and use it in GitHub Desktop.
Save dorkness-io/5fb35a0e0d9936f0019554d84ec9a62a to your computer and use it in GitHub Desktop.
An example to illustrate how unions work. This query unions the os_currentstep and os_historystep table to get the timestamps of all status transitions for issues. You'd be much better off using changegroup/changeitem without a union, but I needed an example :)
select
p.pkey || '-' || ji.issuenum AS issue_key
,cs.start_date
from jiraissue ji
join project p
on ji.project = p.id
join os_currentstep cs
on ji.workflow_id = cs.entry_id
union
select
p.pkey || '-' || ji.issuenum AS issue_key
,hs.start_date
from jiraissue ji
join project p
on ji.project = p.id
join os_historystep hs
on ji.workflow_id = hs.entry_id
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment