Advertisement
roganhamby

Circ Analysis By Copy Locations for York

Jan 8th, 2014
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. create table rogan.peel as
  3. select distinct acl.name from asset.copy_location acl
  4. join actor.org_unit aou on aou.id = acl.owning_lib
  5. join actor.org_unit org on org.id = aou.parent_ou
  6. where org.shortname = 'YCL'
  7. ;
  8.  
  9. alter table rogan.peel add column blah text;
  10.  
  11. select * from rogan.peel;
  12.  
  13. update rogan.peel set blah = 'Non Circulating' where name in ('Young Adult Reference','Juvenile Reference','Shasta''s Desk','Periodical Storage','Book Club','Technology Center','Technical Services','Closed Stack','Reference','Reference Desk','Retired Reference','Atlas Table','Microfilm','kinder box','kinder box items','Infotrac Index','Infotrac Microfilm','Infotrac Full Text','Professional','Reference Desk','Ready Reference','Index Table');
  14. update rogan.peel set blah = 'Periodicals' where name in ('Young Adult Periodicals','Browsing Periodicals','Juvenile Periodicals');
  15. update rogan.peel set blah = 'Juvenile Fiction' where name in ('Juvenile Newbery Award','Juvenile Caldecott Award','Juvenile Paperbacks','Juvenile Read-Alongs','Juvenile Easy');
  16. update rogan.peel set blah = 'Juvenile Video' where name in ('Juvenile Video Cassettes','Juvenile DVD');
  17. update rogan.peel set blah = 'Spanish' where name in ('Juvenile Spanish','Adult Spanish');
  18. update rogan.peel set blah = 'Audio Books' where name in ('Books On CD (Full-Length)','Books on CD (Abridged)','Books on Cassette (Abridged)','Books on Cassette (Full-Length)');
  19. update rogan.peel set blah = 'Graphic Novels' where name in ('Young Adult Graphic Novel','Juvenile Graphic Novel');
  20. update rogan.peel set blah = 'Adult Fiction' where name in ('On Display','New Books -- Adult Fiction','Paperbacks');
  21. update rogan.peel set blah = 'Adult NonFiction' where name in ('New Books -- Adult Nonfiction');
  22. update rogan.peel set blah = 'Downloadables' where name in ('Downloadable Audiobook','Juvenile Downloadable Audiobook','Downloadable E-Book','Young Adult Downloadable Audiobook');
  23. update rogan.peel set blah = 'Adult Videos' where name in ('DVD','Video Cassettes');
  24. update rogan.peel set blah = 'Large Print' where name in ('New Books -- Large Print');
  25. update rogan.peel set blah = 'Special Collection' where name in ('Special Collection Fiction','Special Collection Nonfiction','Special Collection Periodicals','Juvenile Special Collection');
  26. update rogan.peel set blah = 'Juvenile Nonfiction' where name in ('Class Project Table','Resources For Early Childhood');
  27. update rogan.peel set blah = 'Juvenile Audiobooks' where name in ('Juvenile Books On Cassette','Juvenile Books On CD');
  28. update rogan.peel set blah = 'Young Adult' where name in ('Young Adult Paperbacks');
  29. update rogan.peel set blah = name where blah is null;
  30.  
  31.  
  32. -- totals
  33. select count(circ.id), peel.blah
  34. from action.circulation circ
  35. join actor.org_unit org1 on org1.id = circ.circ_lib
  36. join actor.org_unit org2 on org2.id = org1.parent_ou
  37. join asset.copy ac on ac.id = circ.target_copy
  38. join asset.call_number call on call.id = ac.call_number
  39. join asset.copy_location acl on acl.id = ac.location
  40. join rogan.peel peel on peel.name = acl.name
  41. where date(circ.xact_start) >= '2012-01-01' and date(circ.xact_start) <= '2012-12-31' and org2.shortname = 'YCL'
  42. group by 2
  43. order by 2 ASC
  44. ;
  45.  
  46.  
  47. select distinct blah from rogan.peel;
  48.  
  49. -- new items
  50. select count(ac.id), peel.blah
  51. from asset.copy ac
  52. join actor.org_unit org1 on org1.id = ac.circ_lib
  53. join actor.org_unit org2 on org2.id = org1.parent_ou
  54. join asset.call_number call on call.id = ac.call_number
  55. join asset.copy_location acl on acl.id = ac.location
  56. join rogan.peel peel on peel.name = acl.name
  57. where date(ac.create_date) >= '2012-01-01' and date(ac.create_date) <= '2012-12-31' and org2.shortname = 'YCL'
  58. group by 2
  59. order by 2 ASC
  60. ;
  61.  
  62.  
  63. -- monthl
  64.  
  65. select count(circ.id), extract(month from circ.xact_start), peel.blah
  66. from action.circulation circ
  67. join actor.org_unit org1 on org1.id = circ.circ_lib
  68. join actor.org_unit org2 on org2.id = org1.parent_ou
  69. join asset.copy ac on ac.id = circ.target_copy
  70. join asset.call_number call on call.id = ac.call_number
  71. join asset.copy_location acl on acl.id = ac.location
  72. join rogan.peel peel on peel.name = acl.name
  73. where date(circ.xact_start) >= '2012-01-01' and date(circ.xact_start) <= '2012-12-31' and org2.shortname = 'YCL'
  74. group by 2, 3
  75. order by 2, 3 ASC
  76. ;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement