Skip to content

Instantly share code, notes, and snippets.

@stompro
Created July 13, 2016 15:44
Show Gist options
  • Save stompro/2b2e96dc1b9907193c83469cc3222edc to your computer and use it in GitHub Desktop.
Save stompro/2b2e96dc1b9907193c83469cc3222edc to your computer and use it in GitHub Desktop.
Report Copy Status by circ lib evergreen
-- List counts of copy statuses by circ lib
select aou.shortname,cs.name as status,count(ac.id),now()
from asset.copy ac
join config.copy_status cs on (ac.status=cs.id)
join actor.org_unit aou on aou.id=ac.circ_lib
where ac.deleted=false
-- and ac.circ_lib in (SELECT id FROM actor.org_unit_descendants(127))
group by aou.shortname,cs.name
order by aou.shortname,cs.name
;
-- list counts of copy statuses by circ lib and circ_mod
select aou.shortname,ac.circ_modifier, cs.name as status,count(ac.id),now()
from asset.copy ac
join config.copy_status cs on (ac.status=cs.id)
join actor.org_unit aou on aou.id=ac.circ_lib
where ac.deleted=false
-- and ac.circ_lib in (SELECT id FROM actor.org_unit_descendants(127))
group by aou.parent_ou,aou.shortname,ac.circ_modifier,cs.name
order by aou.parent_ou,aou.shortname,ac.circ_modifier,cs.name
;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment