Advertisement
cmptrwz

Stat Cat Counts

Jul 9th, 2014
279
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.35 KB | None | 0 0
  1. WITH libs AS (SELECT * FROM actor.org_unit_ancestors(<<INSERT LIBRARY ID HERE>>))
  2. SELECT count(distinct acsc.id) AS stat_cat_count, count(distinct acsce.id) AS stat_cat_entry_count
  3. FROM actor.stat_cat acsc
  4. LEFT JOIN actor.stat_cat_entry acsce ON acsce.stat_cat = acsc.id AND acsce.owner IN (SELECT id FROM libs)
  5. WHERE acsc.owner IN (SELECT id FROM libs);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement