Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- WITH libs AS (SELECT * FROM actor.org_unit_ancestors(<<INSERT LIBRARY ID HERE>>))
- SELECT count(distinct acsc.id) AS stat_cat_count, count(distinct acsce.id) AS stat_cat_entry_count
- FROM actor.stat_cat acsc
- LEFT JOIN actor.stat_cat_entry acsce ON acsce.stat_cat = acsc.id AND acsce.owner IN (SELECT id FROM libs)
- WHERE acsc.owner IN (SELECT id FROM libs);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement