Advertisement
roganhamby

Simple Patron Counts

Dec 30th, 2013
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. -- create date isn't important so long as the account is still valid
  3. -- expire_date is because it should only look three years out for the expiration
  4.  
  5. -- same forumla as always used but adjusted in 2012 per board to change interval to 3 years
  6.  
  7. select count(au.id) AS "Number of Patrons", paou.name AS "Library Name"
  8. from actor.usr au
  9. join actor.org_unit aou on aou.id = au.home_ou
  10. join actor.org_unit paou on paou.id = aou.parent_ou
  11. where au.active = TRUE
  12. and au.deleted = FALSE
  13. and au.expire_date < now() + interval '3 years'
  14. group by paou.name
  15. order by paou.name
  16. ;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement