Skip to content

Instantly share code, notes, and snippets.

@jeff
Created February 17, 2017 21:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeff/d8728bed86820e45a2bdbaef95ff1b50 to your computer and use it in GitHub Desktop.
Save jeff/d8728bed86820e45a2bdbaef95ff1b50 to your computer and use it in GitHub Desktop.
-- display count of circ matrix matchpoints that reference circ duration rules, grouped by org unit.
-- include unused circ duration rules (count = 0)
SELECT
ccmm.org_unit,
aou.shortname,
COUNT(ccmm.*),
crdd.id,
crdd.name,
CASE WHEN crdd.shrt = crdd.normal THEN NULL
ELSE crdd.shrt
END,
crdd.normal,
CASE WHEN crdd.extended = crdd.normal THEN NULL
ELSE crdd.extended
END,
crdd.max_renewals
FROM config.rule_circ_duration crdd
LEFT JOIN config.circ_matrix_matchpoint ccmm ON ccmm.duration_rule = crdd.id
LEFT JOIN actor.org_unit aou ON ccmm.org_unit = aou.id
GROUP BY ccmm.org_unit, aou.shortname, crdd.id, crdd.name, crdd.extended, crdd.normal, crdd.shrt, crdd.max_renewals
ORDER BY ccmm.org_unit, crdd.normal, crdd.max_renewals, crdd.id;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment