Advertisement
roganhamby

Summer Reading Report

Sep 26th, 2013
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- Summer reading report
  2. -- this is based off copy location name because we use an internal convention within SCLENDS
  3. -- of appropriate shelving locations starting with "Young Adult" or "Juvenile"
  4.  
  5.  
  6. -- circ by juv
  7. SELECT COUNT(circ.id) AS "Juvenile Circs", org2.shortname
  8. FROM ACTION.circulation circ
  9. JOIN actor.org_unit org ON org.id = circ.circ_lib
  10. JOIN actor.org_unit org2 ON org2.id = org.parent_ou
  11. JOIN asset.copy_location loc ON loc.id = circ.copy_location
  12. WHERE date(circ.xact_start) >= '2014-06-01' AND date(circ.xact_start) <= '2014-08-15'
  13. AND (loc.NAME iLIKE 'juv%' or loc.NAME iLIKE 'easy%' or loc.NAME iLIKE 'child%' or loc.NAME iLIKE '%parent%')
  14. GROUP BY 2
  15. ORDER BY 2
  16. ;
  17.  
  18. -- circ by young adult
  19. SELECT COUNT(circ.id) AS "Young Adult Circs", org2.shortname
  20. FROM ACTION.circulation circ
  21. JOIN actor.org_unit org ON org.id = circ.circ_lib
  22. LEFT JOIN actor.org_unit org2 ON org2.id = org.parent_ou
  23. JOIN asset.copy_location loc ON loc.id = circ.copy_location
  24. WHERE date(circ.xact_start) >= '2014-06-01' AND date(circ.xact_start) <= '2014-08-15'
  25. AND loc.NAME LIKE 'You%'
  26. GROUP BY 2
  27. ORDER BY 2
  28. ;
  29.  
  30. -- circ by adult
  31. SELECT COUNT(circ.id) AS "Adult Circs", org2.shortname
  32. FROM ACTION.circulation circ
  33. JOIN actor.org_unit org ON org.id = circ.circ_lib
  34. JOIN actor.org_unit org2 ON org2.id = org.parent_ou
  35. JOIN asset.copy_location loc ON loc.id = circ.copy_location
  36. WHERE date(circ.xact_start) >= '2014-06-01' AND date(circ.xact_start) <= '2014-08-15'
  37. AND loc.NAME LIKE 'Adu%'
  38. GROUP BY 2
  39. ORDER BY 2
  40. ;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement