SQL Reports Library

From Koha Wiki

Jump to: navigation, search
Home > Documentation
Home > Documentation > Tips & Tricks

The following SQL statements have been written by Koha users world-wide. Keep in mind that not all reports have been tested and should be read thoroughly before applying them to your own system.

Contents

SQL Reports

Tips

Links

If you want to put links to your report, you can use the SQL's CONCAT keyword in your SELECT clause.

for example, the following SQL Report will list all your biblio with a link to each of them.

SELECT
  biblionumber, 
  CONCAT('<a href=\"/cgi-bin/koha/catalogue/detail.pl?biblionumber=',biblionumber,'\">',title,'</a>') AS Title 
FROM biblio 
ORDER BY biblionumber

Query MARC

MySQL has some XML handling functions (since MySQL 5.1.5): http://dev.mysql.com/doc/refman/5.4/en/xml-functions.html

For example:

 
SELECT 
  ExtractValue((
    SELECT marcxml
    FROM biblioitems
    WHERE
      biblionumber=14),
      '//datafield[@tag="952"]/subfield[@code>="a"]') AS ITEM;

or the equivalent

SELECT
  ExtractValue(marcxml,'//datafield[@tag="952"]/*') AS ITEM
FROM biblioitems
WHERE biblionumber=14;

return the entire 952 data for all 952 fields for biblionumber 14 (without delimiting).

 
SELECT 
  ExtractValue((
    SELECT marcxml 
    FROM biblioitems 
    WHERE biblionumber=14),
      '//datafield[@tag="260"]/subfield[@code="b"]') AS PUBLISHER;

returns the 260$b data for biblionumber 14.

Runtime Parameters

If you feel that your report might be too resource intensive you might want to consider using runtime parameters to your query. Runtime parameters basically make a filter appear before the report is run to save your system resources.

There is a specific syntax that Koha will understand as 'ask for values when running the report'. The syntax is <<Question to ask|authorized_value>>.

  • The << and >> are just delimiters. You must put << at the beginning and >> at the end of your parameter
  • The 'Question to ask' will be displayed on the left of the string to enter.
  • The authorized_value can be omitted if not applicable. If it contains an authorized value category, or branches or itemtype or categorycode, a list with the Koha authorized values will be displayed instead of a free field Note that you can have more than one parameter in a given SQL Note that entering nothing at run time won't probably work as you expect. It will be considered as "value empty" not as "ignore this parameter". For example entering nothing for : "title=<<Enter title>>" will display results with title='' (no title). If you want to have to have something not mandatory, use "title like <<Enter title>>" and enter a % at run time instead of nothing

Examples:

SELECT surname,firstname 
FROM borrowers 
WHERE branchcode=<<Enter patrons library|branches>> AND surname LIKE <<Enter filter FOR patron surname (% IF none)>>


SELECT * 
FROM items 
WHERE homebranch = <<Pick your branch|branches>> AND barcode LIKE <<Partial barcode value here>>

Tip:

You have to put "%" in a text box to 'leave it blank'. Otherwise, it literally looks for "" (empty string) as the value for the field.

SQL Report Summary Template

Report Title

  • Developer: Name of SQL query developer
  • Module: Main module queried by SQL
  • Purpose: Purpose of the SQL query
  • Status: Completed / In progress
Some SQL code

Holds

Duplicate Holds

  • Developer: Liz Rea (NEKLS)
  • Module: Holds
  • Purpose: This report will detect "double-click" placed duplicate holds. Do note that it doesn't necessarily mean anything (currently) as processes done on one of the duplicates will do the same to the other (deleting one deletes both, for example).
  • Status: Completed
SELECT reserves.biblionumber, reserves.borrowernumber, biblio.title, borrowers.firstname, borrowers.surname 
FROM reserves 
LEFT JOIN biblio ON (reserves.biblionumber=biblio.biblionumber) 
LEFT JOIN borrowers ON (reserves.borrowernumber=borrowers.borrowernumber) 
GROUP BY reserves.borrowernumber, reserves.biblionumber 
HAVING (COUNT(reserves.borrowernumber)>=2 AND COUNT(reserves.biblionumber)>=2)

List of Patrons with Holds Awaiting Pickup

  • Developer: Bev Church
  • Module: Holds
  • Purpose: List of all patrons at branch with holds awaiting pickup. So list can be exported from system and merged with a word processing notification document
  • Status: Complete
SELECT
  borrowers.surname,
  borrowers.firstname, 
  borrowers.address, 
  borrowers.city, 
  borrowers.zipcode, 
  reserves.waitingdate AS 'hold date',
  items.barcode,
  biblio.title
FROM
  reserves,
  borrowers,
  items,
  biblio 
WHERE
  reserves.borrowernumber = borrowers.borrowernumber
AND
  reserves.itemnumber = items.itemnumber
AND
  items.biblionumber = biblio.biblionumber
AND
  priority = 0
AND
  waitingdate IS NOT NULL
AND
  reserves.branchcode = 'XXXXX'


Count of hold filled by another branch

  • Developer: Nicole C. Engard, ByWater Solutions
  • Module: Holds
  • Purpose: Holds filled by a branch other than the items homebranch for a year broken down by month
  • Status: Complete
SELECT items.homebranch, old_reserves.branchcode, monthname(old_reserves.reservedate) AS month, 
       year(old_reserves.reservedate) AS year, count(*) 
FROM old_reserves 
LEFT JOIN items 
ON (items.itemnumber=old_reserves.itemnumber) 
WHERE old_reserves.branchcode != items.homebranch AND year(old_reserves.reservedate) = <<Year>> 
GROUP BY month(old_reserves.reservedate), old_reserves.branchcode

List of all Patrons from a Single Branch with open Hold Requests

  • Developer: Jane Wagner, PTFS
  • Module: Holds
  • Purpose: Monthly holds placed by branch (counts holds placed in that month that have not been filled)
  • Status: Complete
SELECT borrowers.surname, borrowers.firstname, borrowers.cardnumber, reserves.reservedate 
AS 'date reserved', reserves.priority, biblio.title, 
IF( LOCATE('<datafield tag="020"', biblioitems.marcxml) = 0 OR LOCATE('<subfield code="a">', biblioitems.marcxml, 
LOCATE('<datafield tag="020"', biblioitems.marcxml)) = 0 OR LOCATE('<subfield code="a">', biblioitems.marcxml, 
LOCATE('<datafield tag="020"', biblioitems.marcxml)) > LOCATE('</datafield>', biblioitems.marcxml, LOCATE('<datafield tag="020"', biblioitems.marcxml)), '', 
SUBSTRING( biblioitems.marcxml,
LOCATE('<subfield code="a">', biblioitems.marcxml, LOCATE('<datafield tag="020"', biblioitems.marcxml)) + 19, 
LOCATE('</subfield>', biblioitems.marcxml, LOCATE('<subfield code="a">', biblioitems.marcxml, 
LOCATE('<datafield tag="020"', biblioitems.marcxml)) + 19) -(LOCATE('<subfield code="a">', biblioitems.marcxml, 
LOCATE('<datafield tag="020"', biblioitems.marcxml)) + 19))) 
AS ISBN FROM reserves, borrowers, biblio, biblioitems WHERE reserves.borrowernumber = borrowers.borrowernumber 
AND reserves.biblionumber = biblio.biblionumber AND reserves.biblionumber = biblioitems.biblionumber 
AND reserves.branchcode = 'XXXXXX' AND reserves.priority = 0

List of all items currently on loan to another library

  • Developer: Nora Blake and Bev Church
  • Module: Holds
  • Purpose: List of all items currently on loan to another library (includes title and call #)
  • Status: Complete
SELECT
  biblio.title,
  items.itemcallnumber, 
  items.holdingbranch,
  items.homebranch, 
  items.barcode, 
  issues.issuedate 
FROM issues 
LEFT JOIN items ON issues.itemnumber=items.itemnumber 
LEFT JOIN biblio ON items.biblionumber=biblio.biblionumber 
WHERE
  issues.branchcode != <<Issuing branch|branches>>
  AND
  items.homebranch = <<Owning branch|branches>>
ORDER BY
  items.homebranch, issues.issuedate, biblio.title

List of all items currently borrowed from another library

  • Developer: Nora Blake and Bev Church
  • Module: Holds
  • Purpose: List of all items currently borrowed from another library (includes title and call #)
  • Status: Complete
SELECT
  biblio.title,
  items.itemcallnumber, 
  items.holdingbranch,
  items.homebranch, 
  items.barcode, 
  issues.issuedate 
FROM issues 
LEFT JOIN items ON issues.itemnumber=items.itemnumber 
LEFT JOIN biblio ON items.biblionumber=biblio.biblionumber 
WHERE 
  issues.branchcode= <<Issuing branch|branches>>
  AND 
  items.holdingbranch !=  items.homebranch 
ORDER BY
  items.homebranch, issues.issuedate, biblio.title

Monthly holds placed by branch

  • Developer: Jane Wagner, PTFS
  • Module: Holds
  • Purpose: Monthly holds placed by branch (counts holds placed in that month that have not been filled)
  • Status: Complete
SELECT count(*),branchcode
FROM reserves
WHERE
 reservedate >= concat(date_format(LAST_DAY(now() - interval 1 month),'%Y-%m-'),'01')
AND
 reservedate <= LAST_DAY(now() - interval 1 month)
GROUP BY branchcode

Monthly holds placed and filled by branch

  • Developer: Jane Wagner, PTFS
  • Module: Holds
  • Purpose: Monthly holds placed and filled by branch (counts holds both placed and filled in that month)
  • Status: Complete
SELECT count(*), branchcode
FROM old_reserves
WHERE
 (timestamp LIKE concat(date_format(LAST_DAY(now() - interval 1 month),'%Y-%m-%')))
AND
  (reservedate >= concat(date_format(LAST_DAY(now() - interval 1 month),'%Y-%m-'),'01')
AND
 reservedate <= LAST_DAY(now() - interval 1 month))
AND Found = 'F'
GROUP BY branchcode

Monthly holds filled by branch

  • Developer: Jane Wagner, PTFS
  • Module: Holds
  • Purpose: Monthly holds filled by branch (counts all holds filled in that month regardless of when placed)
  • Status: Complete
SELECT count(*),branchcode
FROM old_reserves 
WHERE
 (timestamp LIKE concat(date_format(LAST_DAY(now() - interval 1 month),'%Y-%m-%')))
AND
 Found = 'F'
GROUP BY branchcode


Overdues With Holds Waiting

  • Developer: Nicole C. Engard, ByWater Solutions
  • Module: Holds/Circulation
  • Purpose: A list of items that are overdue that have holds on them. A report to help you know who to call with overdues to tell them others are waiting for their items
  • Status: Complete
SELECT borrowers.cardnumber, borrowers.surname, borrowers.firstname, 
       borrowers.phone, borrowers.address, borrowers.city, borrowers.zipcode, 
       issues.date_due, 
       (TO_DAYS(curdate())-TO_DAYS( date_due)) AS 'days overdue', 
       items.itype, biblio.title, biblio.author, items.itemcallnumber, 
       items.barcode, COUNT(reserves.biblionumber) AS 'holds' 
FROM borrowers 
LEFT JOIN issues ON (borrowers.borrowernumber=issues.borrowernumber) 
LEFT JOIN items ON (issues.itemnumber=items.itemnumber) 
LEFT JOIN biblio ON (items.biblionumber=biblio.biblionumber) 
LEFT JOIN reserves ON (biblio.biblionumber=reserves.biblionumber) 
WHERE issues.branchcode = <<Branch Code|branches>>
GROUP BY reserves.biblionumber 
HAVING COUNT(reserves.biblionumber) > 0 
ORDER BY borrowers.surname ASC, issues.date_due ASC

Top 10 Titles Placed on Hold in the Last 6 Months

  • Developer: Nicole C. Engard, ByWater Solutions
  • Module: Holds/Circulation
  • Purpose: Top 10 titles placed on hold in the last 6 months showing titles, authors and ccode.
  • Status: Complete


SELECT count(*) AS holds, title, author, ccode 
FROM (
SELECT biblio.title, biblio.author, items.ccode, biblio.biblionumber
FROM reserves 
LEFT JOIN biblio ON (reserves.biblionumber=biblio.biblionumber)
LEFT JOIN items ON (biblio.biblionumber=items.biblionumber)
WHERE DATE(reserves.timestamp) > DATE_SUB(CURRENT_DATE(),INTERVAL 6 MONTH) 
      AND DATE(reserves.timestamp) <=CURRENT_DATE()
UNION ALL
SELECT biblio.title, biblio.author, items.ccode, biblio.biblionumber
FROM old_reserves 
LEFT JOIN biblio ON (old_reserves.biblionumber=biblio.biblionumber)
LEFT JOIN items ON (biblio.biblionumber=items.biblionumber)
WHERE DATE(old_reserves.timestamp) > DATE_SUB(CURRENT_DATE(),INTERVAL 6 MONTH) 
      AND DATE(old_reserves.timestamp) <=CURRENT_DATE()
 ) AS myholds 
GROUP BY biblionumber 
ORDER BY holds DESC 
LIMIT 10


Holds to Pull

  • Developer: Nicole C. Engard, ByWater Solutions
  • Module: Holds/Circulation
  • Purpose: List items that are on hold, not checked out and not waiting on the holds shelf.
  • Status: Complete


SELECT b.title, i.itemcallnumber, date(r.timestamp) AS "hold date"  
FROM reserves r 
LEFT JOIN biblio b ON (r.biblionumber=b.biblionumber) 
LEFT JOIN items i ON (i.biblionumber=b.biblionumber) 
WHERE i.itemnumber NOT IN (SELECT issues.itemnumber FROM issues) 
      AND r.waitingdate IS NULL 
ORDER BY r.timestamp ASC

Holds to Pull at Branch

  • Developer: Nicole C. Engard, ByWater Solutions
  • Module: Holds/Circulation
  • Purpose: List items that are on hold, not checked out and not waiting on the holds shelf at a specific branch.
  • Status: Complete


SELECT b.title, b.author, i.itemcallnumber, i.barcode, 
       date(r.timestamp) AS "hold date", r.branchcode AS 'pickup branch', 
       i.homebranch AS 'owning branch', p.surname, p.firstname, p.cardnumber
FROM reserves r
LEFT JOIN biblio b ON (r.biblionumber=b.biblionumber)
LEFT JOIN items i ON (i.biblionumber=b.biblionumber)
LEFT JOIN borrowers p USING (borrowernumber)
WHERE i.itemnumber NOT IN (SELECT issues.itemnumber FROM issues)
     AND i.itemnumber NOT IN (SELECT branchtransfers.itemnumber FROM branchtransfers WHERE datearrived IS NULL) 
     AND r.waitingdate IS NULL AND i.homebranch=<<Branch filled at|branches>>
GROUP BY b.biblionumber,p.borrowernumber
ORDER BY i.itemcallnumber ASC

Count of Holds by Month

  • Developer: Nicole C. Engard, ByWater Solutions
  • Module: Holds/Circulation
  • Purpose: This report asks for you to enter a year (twice) and then shows you holds counts for all months that year.
  • Status: Complete


SELECT month, sum(count) AS holds
FROM (
SELECT MONTHNAME(reservedate) AS month, count(*) AS count
FROM reserves
WHERE YEAR(reservedate) = <<Hold Year (yyyy)>>
GROUP BY month
UNION ALL
SELECT MONTHNAME(reservedate) AS month, count(*) AS count
FROM old_reserves
WHERE YEAR(reservedate) = <<Repeat Hold Year (yyyy)>>
GROUP BY month
) AS myholds
GROUP BY month
ORDER BY month ASC


Cancelled Holds

  • Developer: Nicole C. Engard, ByWater Solutions
  • Module: Holds
  • Purpose: A list of holds that were cancelled by branch and date range
  • Status: Complete
SELECT b.title, b.author, p.surname, p.firstname, r.reservedate, 
       r.cancellationdate, r.branchcode 
FROM old_reserves r 
LEFT JOIN biblio b USING (biblionumber) 
LEFT JOIN borrowers p USING (borrowernumber) 
WHERE r.cancellationdate BETWEEN <<Cancelled BETWEEN (yyyy-mm-dd)>> 
      AND <<and (yyyy-mm-dd)>> AND r.branchcode =<<Branch|branches>>

Patron Reports

New Patron List (previous month)

  • Developer: Jane Wagner, PTFS
  • Module: circ
  • Purpose:
  • Status: Complete


SELECT borrowers.cardnumber, borrowers.surname, borrowers.firstname, borrowers.dateenrolled 
FROM borrowers 
WHERE borrowers.dateenrolled >= concat(date_format(LAST_DAY(now() - interval 1 month),'%Y-%m-'),'01') AND borrowers.dateenrolled <= LAST_DAY(now() - interval 1 month) 
ORDER BY borrowers.surname ASC

Patron Birthday Report

  • Developer: Nicole C. Engard, ByWater Solutions
  • Module: patrons
  • Purpose: Patrons who are under the age of 17 that have a birthday this month
  • Status: Complete


SELECT firstname, surname, address, address2, city, 
       zipcode, dateofbirth 
FROM borrowers 
WHERE MONTH(dateofbirth) = <<Month (mm)>> 
      AND DATEDIFF(<<Last date of month (yyyy-mm-dd)>>, dateofbirth) < ((17*365)+4)


Patrons of specific age range

  • Developer: Nicole C. Engard, ByWater Solutions
  • Module: patrons
  • Purpose: This report shows patrons between the age of 12 and 13
  • Status: Complete
SELECT cardnumber, firstname, surname, dateofbirth, 
      (YEAR(CURDATE( )) - YEAR(dateofbirth) - IF(RIGHT(CURDATE( ),5) < RIGHT(dateofbirth,5),1,0)) AS 'age in years', 
      categorycode 
FROM borrowers 
WHERE DATEDIFF(now(), dateofbirth) < ((13*365)+4) 
      AND DATEDIFF(now(), dateofbirth) > ((12*365)+4)

Patrons with Staff Permissions

  • Developer: Ian Walls, ByWater Solutions
  • Module: Patrons
  • Purpose: List of patrons/staff with their permission levels
  • Status: Complete
SELECT borrowernumber, firstname, surname, categorycode, 
       description, flags 
FROM borrowers 
JOIN user_permissions USING (borrowernumber) 
JOIN permissions USING (code) 
UNION (
      SELECT borrowernumber, firstname, surname, 
             categorycode, 'module-level permissions; 
             1 is superlibrarian' AS description, flags 
      FROM borrowers 
      WHERE flags > 0) 
ORDER BY borrowernumber ASC

Superlibrarians

  • Developer: Nicole C. Engard, ByWater Solutions
  • Module: Patrons
  • Purpose: List of patrons/staff with superlibrarian permission
  • Status: Complete
SELECT firstname, surname, borrowernumber 
FROM borrowers 
WHERE flags='1'

New Patrons

  • Developer: Sharon Moreland
  • Module: Circulation
  • Purpose: New patrons added
  • Status: Complete


  SELECT branchcode,categorycode,COUNT(*)
  FROM borrowers WHERE MONTH(dateenrolled) = <<Month enrolled (mm)>> AND YEAR(dateenrolled)= <<Year enrolled (yyyy)>>
  GROUP BY branchcode,categorycode 
  ORDER BY branchcode

Expired Patrons w/out Checkouts

  • Developer: Nicole C. Engard, ByWater Solutions
  • Module: Patrons
  • Purpose: List patrons expired in a specific year who do not currently have any checkouts
  • Status: Complete
  SELECT borrowers.surname, borrowers.firstname, borrowers.borrowernumber 
  FROM borrowers 
  WHERE borrowernumber 
  NOT IN (SELECT borrowernumber FROM issues) 
  AND YEAR(borrowers.dateexpiry) = <<Year>>

Missing Emails

  • Developer: Sharon Moreland
  • Module: Patrons
  • Purpose: Missing e-mails
  • Status: Complete


 SELECT cardnumber, surname, firstname, branchcode, debarred, dateexpiry 
  FROM borrowers 
  WHERE ' ' IN (email)

Patrons w/ Checked Out Items

  • Developer: Nora Blake
  • Module: Circulation
  • Purpose: List of items checked out to patrons according to data contained in Sort field
  • Status: Complete


  SELECT issues, biblio.title, author, surname, firstname, borrowers.sort1, 
         items.itemcallnumber, items.barcode, issues.issuedate, issues.lastreneweddate 
  FROM issues 
  LEFT JOIN borrowers ON borrowers.borrowernumber=issues.borrowernumber 
  LEFT JOIN items ON issues.itemnumber=items.itemnumber 
  LEFT JOIN biblio ON items.biblionumber=biblio.biblionumber 
  WHERE issues.branchcode='LIBRARY' AND sort1='2009'
  ORDER BY issues.branchcode, borrowers.sort1, borrowers.surname, issues.issuedate, biblio.title

New Patron Count (previous month)

  • Developer: Jane Wagner, PTFS
  • Module: Patron
  • Purpose:
  • Status: Complete


SELECT COUNT(*) AS 'New Patrons Last Month' 
FROM borrowers 
WHERE borrowers.dateenrolled >= concat(date_format(LAST_DAY(now() - interval 1 month),'%Y-%m-'),'01') AND borrowers.dateenrolled <= LAST_DAY(now() - interval 1 month)

New Patron Count (by Branch/Category) (previous month)

  • Developer: Jane Wagner, PTFS
  • Module: Patron
  • Purpose: Count of new patrons enrolled in the previous month, by branch and category code
  • Status: Complete


SELECT branchcode, categorycode, COUNT(branchcode) AS NumberEnrolled 
FROM borrowers 
WHERE borrowers.dateenrolled >= concat(date_format(LAST_DAY(now() - interval 1 month),'%Y-%m-'),'01') AND borrowers.dateenrolled <= LAST_DAY(now() - interval 1 month) 
GROUP BY branchcode, categorycode

New Patrons by Branch (year to date)

  • Developer: Jane Wagner, PTFS
  • Module: Patron
  • Purpose:
  • Status: Complete


SELECT branchcode, categorycode, COUNT(branchcode) AS NumberEnrolled 
FROM borrowers 
WHERE YEAR(borrowers.dateenrolled) = YEAR(NOW()) 
GROUP BY branchcode, categorycode


Count of Expired Patrons

  • Developer: Nicole C. Engard, ByWater Solutions
  • Module: Patrons
  • Purpose: Count of patrons who's cards have expired before today
  • Status: Complete
SELECT COUNT(borrowers.cardnumber) AS count
FROM borrowers  
WHERE borrowers.dateexpiry > <<Today's Date (yyyy-mm-dd)>>

Patrons with All Attribute Values

  • Developer: Nicole C. Engard, ByWater Solutions
  • Module: Patrons
  • Purpose: Patron list with the value of all of their custom patron attributes
  • Status: Complete
SELECT borrowers.surname, borrowers.firstname, borrowers.cardnumber, borrower_attributes.code, borrower_attributes.attribute 
FROM borrowers 
LEFT JOIN borrower_attributes ON (borrowers.borrowernumber=borrower_attributes.borrowernumber) 
LEFT JOIN borrower_attribute_types ON (borrower_attribute_types.code=borrower_attributes.code) 
GROUP BY borrower_attributes.attribute 
ORDER BY borrowers.surname, borrowers.firstname ASC

Patrons with a Specific Attribute Value

  • Developer: Nicole C. Engard, ByWater Solutions
  • Module: Patrons
  • Purpose: Patron list with the value of one of their custom patron attributes (student id)
  • Status: Complete
SELECT borrowers.surname, borrowers.firstname, 
       borrowers.cardnumber, borrower_attributes.attribute AS 'Attribute' 
FROM borrowers 
LEFT JOIN borrower_attributes ON (borrowers.borrowernumber=borrower_attributes.borrowernumber) 
LEFT JOIN borrower_attribute_types ON (borrower_attribute_types.code=borrower_attributes.code) 
WHERE borrower_attributes.code = <<Attribute Code>>

Duplicate Patrons

  • Developer: Nicole C. Engard, ByWater Solutions
  • Module: Patrons
  • Purpose: List of patrons who are potentially duplicates
  • Status: Complete
SELECT surname, firstname, GROUP_CONCAT(cardnumber SEPARATOR ', ') AS barcodes, 
       GROUP_CONCAT(borrowernumber SEPARATOR ', ') AS borrowers 
FROM borrowers 
GROUP BY CONCAT(surname,"/",firstname,"/") 
HAVING COUNT(CONCAT(surname,"/",firstname,"/"))>1

Restricted Patrons

  • Developer: Ian Walls, ByWater Solutions
  • Module: Patrons
  • Purpose: List of patrons who have been marked as restricted
  • Status: Complete
SELECT borrowers.cardnumber, borrowers.surname, borrowers.firstname,
       borrowers.debarred 
FROM borrowers 
WHERE borrowers.branchcode=<<Select your branch|branches>> AND borrowers.debarred='1' 
ORDER BY borrowers.surname ASC, borrowers.firstname ASC

Patrons with notes or messages

  • Developer: Nicole C. Engard, ByWater Solutions
  • Module: Patrons
  • Purpose: Patrons with notes and messages on their accounts
  • Status: Completed
SELECT b.cardnumber, b.surname, b.firstname,
b.opacnote, b.borrowernotes, group_concat(DISTINCT m.message separator ', ') AS circmesages
FROM borrowers b
LEFT JOIN messages m USING (borrowernumber)
WHERE b.branchcode=<<Branch|branches>> AND ((b.opacnote IS NOT
NULL AND b.opacnote != '') OR (b.borrowernotes IS NOT NULL AND
b.borrowernotes != '') OR (m.message IS NOT NULL AND
m.message != '')) GROUP BY b.borrowernumber ORDER BY b.surname ASC,
b.firstname ASC

Patrons with No Checkouts

  • Developer: Nicole C. Engard, ByWater Solutions
  • Module: Patrons
  • Purpose: Patrons who haven't checked out in a specific timeframe
  • Status: Completed
SELECT surname, firstname, cardnumber
FROM borrowers
WHERE borrowernumber NOT IN 
     (SELECT DISTINCT borrowernumber 
      FROM statistics 
      WHERE type = 'issue' AND 
      datetime BETWEEN <<Between (yyyy-mm-dd)>> AND <<and (yyyy-mm-dd)>>)


Patron with messages but no email

  • Developer: Amy Boisvert, VOKAL
  • Module: Patrons
  • Purpose: Patrons with email addresses that do not have the patron messaging preference for holds checked.
  • Status: Completed
SELECT b.surname, b.firstname, b.cardnumber, b.email
FROM borrowers b
     LEFT JOIN (SELECT p.borrowernumber
                FROM borrower_message_preferences p 
                INNER JOIN borrower_message_transport_preferences t
                ON p.borrower_message_preference_id=t.borrower_message_preference_id
                WHERE p.message_attribute_id=4) e 
     ON b.borrowernumber=e.borrowernumber
WHERE b.branchcode=<<Your branch|branches>>
AND IFNULL(b.email,'') <>'' AND e.borrowernumber IS NULL

Active Patrons

  • Developer: Mike Hafen
  • Module: Patrons
  • Purpose: A report for finding patrons who are checking out materials
  • Status: Completed
SELECT YEAR(issuedate), MONTH(issuedate), categorycode, COUNT(DISTINCT borrowernumber)
FROM (
  SELECT issuedate, borrowernumber FROM old_issues
 UNION ALL
  SELECT issuedate, borrowernumber FROM issues
) AS all_issues
LEFT JOIN borrowers USING (borrowernumber)
GROUP BY YEAR(issuedate), MONTH(issuedate), categorycode

Circulation Reports

Circulation of Two Call Numbers

  • Developer: Nicole C. Engard, ByWater Solutions
  • Module: Circulation
  • Purpose: Circulation using two call numbers (or call number ranges) for a specific time frame
  • Example: Using YA% and J% as the call numbers gets you all Juvenile materials if your library uses Dewey
  • Status: Complete
SELECT statistics.branch, month(statistics.datetime) AS month, 
       year(statistics.datetime) AS year, count(statistics.datetime) AS count 
FROM statistics 
LEFT JOIN items ON (statistics.itemnumber = items.itemnumber) 
WHERE statistics.type LIKE 'issue' 
       AND (items.itemcallnumber LIKE <<Call Number (USE % FOR wildcard)>> OR items.itemcallnumber LIKE <<Second Call Number (USE % FOR wildcard)>>) 
       AND date(statistics.datetime) BETWEEN <<Between (yyyy-mm-dd)>> AND <<and (yyyy-mm-dd)>> 
GROUP BY statistics.branch, year, month 
ORDER BY year, month DESC, statistics.branch ASC

Track In House Use

  • Developer: Nicole C. Engard, ByWater Solutions
  • Module: Circulation
  • Purpose: Find out local use circ numbers for a specific time frame
  • Status: Complete
SELECT count(*) 
FROM statistics 
WHERE type='localuse' 
AND datetime BETWEEN <<Local USE BETWEEN (yyyy-mm-dd)>> AND <<and (yyyy-mm-dd)>>

Track In House Use Hourly

  • Developer: Nicole C. Engard, ByWater Solutions
  • Module: Circulation
  • Purpose: Number of internal circs on a particular day in a particular time range
  • Status: Complete
SELECT hour(datetime) AS hour, count(*) AS count 
FROM statistics 
WHERE type='localuse' AND date(datetime)=<<Date (yyyy-mm-dd)>> 
      AND time(datetime) BETWEEN <<Time BETWEEN (hh:mm)>> 
      AND <<and (hh:mm)>>


Track In House Use in Hourly Range

  • Developer: Nicole C. Engard, ByWater Solutions
  • Module: Circulation
  • Purpose: Number of internal circs broken out by hour on a particular day
  • Status: Complete
SELECT hour(datetime) AS hour, count(*) AS count 
FROM statistics 
WHERE type='localuse' AND date(datetime)=<<Date (yyyy-mm-dd)>>

All Checked Out Books

  • Developer: Nicole C. Engard, ByWater Solutions
  • Module: Circulation
  • Purpose: A report to show you all items that are currently checked out and who they're checked out to
  • Status: Complete
SELECT issues.date_due, borrowers.surname, borrowers.firstname,
       borrowers.phone, borrowers.email, biblio.title, biblio.author,
       items.itemcallnumber, items.barcode, items.location 
FROM issues 
LEFT JOIN items ON (issues.itemnumber=items.itemnumber) 
LEFT JOIN borrowers ON (issues.borrowernumber=borrowers.borrowernumber) 
LEFT JOIN biblio ON (items.biblionumber=biblio.biblionumber) 
ORDER BY issues.date_due ASC

Overdues w/ Contact Info

  • Developer: Nicole C. Engard, ByWater Solutions
  • Module: Circulation
  • Purpose: A report that shows items overdue more than a specific number of days for contacting the patrons.
  • Status: Complete
SELECT borrowers.cardnumber, borrowers.surname, borrowers.firstname, 
       borrowers.phone, borrowers.email, issues.date_due, 
       (TO_DAYS(curdate())-TO_DAYS( date_due)) AS 'days overdue', 
       biblio.title, biblio.author, items.itemcallnumber, 
       items.barcode
FROM borrowers 
LEFT JOIN issues ON (borrowers.borrowernumber=issues.borrowernumber) 
LEFT JOIN items ON (issues.itemnumber=items.itemnumber) 
LEFT JOIN biblio ON (items.biblionumber=biblio.biblionumber) 
WHERE issues.branchcode = <<Branch Code>> AND (TO_DAYS(curdate())-TO_DAYS(
date_due)) >= <<Days overdue>>
ORDER BY borrowers.surname ASC, borrowers.firstname ASC, issues.date_due ASC


Overdues by Item Type

  • Developer: Nicole C. Engard, ByWater Solutions
  • Module: Circulation
  • Purpose: A report that shows overdue items based on item type.
  • Status: Complete
SELECT borrowers.cardnumber, borrowers.surname, borrowers.firstname, 
       borrowers.phone, borrowers.address, borrowers.city, borrowers.zipcode, 
       issues.date_due, 
       (TO_DAYS(curdate())-TO_DAYS( date_due)) AS 'days overdue', 
       biblio.title, biblio.author, items.itemcallnumber, 
       items.barcode
FROM borrowers 
LEFT JOIN issues ON (borrowers.borrowernumber=issues.borrowernumber) 
LEFT JOIN items ON (issues.itemnumber=items.itemnumber) 
LEFT JOIN biblio ON (items.biblionumber=biblio.biblionumber) 
WHERE items.itype = <<Item Type|itemtypes>>
ORDER BY borrowers.surname ASC, issues.date_due ASC

Checkouts by Call Number (previous month)

  • Developer: Jane Wagner, PTFS
  • Module: Circ
  • Purpose:
  • Status: Complete


SELECT count(statistics.type) AS 'Checkouts',items.itemcallnumber 
FROM borrowers 
  LEFT JOIN statistics ON (statistics.borrowernumber=borrowers.borrowernumber) 
  LEFT JOIN items ON (items.itemnumber = statistics.itemnumber) 
  LEFT JOIN biblioitems ON (biblioitems.biblioitemnumber = items.biblioitemnumber) 
WHERE statistics.type = 'issue' 
  AND statistics.datetime >= concat(date_format(LAST_DAY(now() - interval 1 month),'%Y-%m-'),'01') 
  AND statistics.datetime <= LAST_DAY(now() - interval 1 month) 
GROUP BY items.itemcallnumber 
ORDER BY items.itemcallnumber ASC

Renewals by Call Number (previous month)

  • Developer: Jane Wagner, PTFS
  • Module: Circ
  • Purpose:
  • Status: Complete


SELECT count(statistics.type) AS 'Renewals',items.itemcallnumber 
FROM borrowers 
  LEFT JOIN statistics ON (statistics.borrowernumber=borrowers.borrowernumber) 
  LEFT JOIN items ON (items.itemnumber = statistics.itemnumber) 
  LEFT JOIN biblioitems ON (biblioitems.biblioitemnumber = items.biblioitemnumber) 
WHERE statistics.type = 'renew'
  AND statistics.datetime >= concat(date_format(LAST_DAY(now() - interval 1 month),'%Y-%m-'),'01')
  AND statistics.datetime <= LAST_DAY(now() - interval 1 month) 
GROUP BY items.itemcallnumber 
ORDER BY items.itemcallnumber ASC


Checkouts by Item Type (previous month)

  • Developer: Galen Charlton, Equinox
  • Module: Circ
  • Purpose:
  • Status: Complete
  • Note: This can take a while to run because of the union of items and deleteditems, but has the advantage that items that get circulated, then deleted, during the previous month will get reported using their correct item type.
SELECT  all_items.itype AS "Item Type" ,count(*) AS 'Checkouts' 
FROM statistics 
JOIN (
  SELECT itemnumber, itype FROM deleteditems
  UNION
  SELECT itemnumber, itype FROM items 
) AS all_items USING (itemnumber)
WHERE statistics.type = 'issue' 
AND statistics.datetime >= concat(date_format(LAST_DAY(now() - interval 1 month),'%Y-%m-'),'01') 
AND statistics.datetime <= LAST_DAY(now() - interval 1 month)
GROUP BY all_items.itype 
ORDER BY all_items.itype ASC;

Previous Day's Circ Stats

  • Developer: Jane Wagner, PTFS
  • Module: Circ
  • Purpose:
  • Status: Complete


SELECT count(statistics.type) AS 'Total', statistics.type 
FROM statistics WHERE statistics.datetime LIKE concat(date_format(LAST_DAY(now() - interval 1 day),'%Y-%m-%')) 
GROUP BY statistics.type 
ORDER BY statistics.type ASC

Previous Month's Circ Stats

  • Developer: Jane Wagner, PTFS
  • Module: Circ
  • Purpose:
  • Status: Complete


SELECT count(statistics.type) AS 'Total', statistics.type 
FROM statistics 
WHERE statistics.datetime >= concat(date_format(LAST_DAY(now() - interval 1 month),'%Y-%m-'),'01') AND statistics.datetime <= LAST_DAY(now() - interval 1 month) 
GROUP BY statistics.type 
ORDER BY statistics.type ASC

Previous Month's Checkouts/Renewals by Collection Code

  • Developer: Jane Wagner, PTFS
  • Module: Circ
  • Purpose:
  • Status: Complete
SELECT items.ccode AS Collection, COUNT( statistics.itemnumber ) AS Count 
FROM statistics 
LEFT JOIN items ON (statistics.itemnumber = items.itemnumber) 
WHERE  (statistics.datetime LIKE concat(date_format(LAST_DAY(now() - interval 1 month),'%Y-%m-%'))) AND statistics.type IN ('issue','renew') 
GROUP BY items.ccode

Previous Month Checkouts/Renews by Patron Category

  • Developer: Jane Wagner, PTFS
  • Module: Circ
  • Purpose:
  • Status: Complete
SELECT borrowers.categorycode AS PatronType, COUNT( statistics.itemnumber ) AS Count 
FROM statistics 
  LEFT JOIN borrowers ON (statistics.borrowernumber = borrowers.borrowernumber) 
WHERE (statistics.datetime LIKE concat(date_format(LAST_DAY(now() - interval 1 month),'%Y-%m-%'))) 
  AND statistics.type IN ('issue','renew') 
GROUP BY borrowers.categorycode

All Circ Actions on Date

  • Developer: Nicole C. Engard, ByWater Solutions
  • Module: Circ
  • Purpose: Give you stats for all circ actions on a specific date
  • Status: Complete
SELECT statistics.type AS action, COUNT(statistics.datetime) AS count 
FROM statistics 
WHERE DATE(statistics.datetime)=<<Date (yyyy-mm-dd)>>
GROUP BY statistics.type;


Checkouts & Renewals in Date Range

  • Developer: Nicole C. Engard, ByWater Solutions
  • Module: Circ
  • Purpose: Asks for date range and shows you the checkouts and renewals
  • Status: Complete
SELECT type, count(datetime) AS count 
FROM statistics 
WHERE datetime BETWEEN <<Checked out BETWEEN (yyyy-mm-dd)>> 
      AND <<and (yyyy-mm-dd)>> AND type IN ('issue','renew') 
GROUP BY type

Weekly Checked Out by Branch

  • Developer: vishnuperumal
  • Module: Circulation
  • Purpose: number of checkouts detail made by branch(Weekly Report)
  • Status: Complete


SELECT borrowers.surname, borrowers.firstname, borrowers.phone, 
       borrowers.cardnumber, borrowers.address, borrowers.city, 
       borrowers.zipcode, issues.date_due, items.itype, items.itemcallnumber, 
       items.barcode, items.homebranch, biblio.title, biblio.author
FROM borrowers 
LEFT JOIN issues ON (borrowers.borrowernumber=issues.borrowernumber)
LEFT JOIN items ON (issues.itemnumber=items.itemnumber)
LEFT JOIN biblio ON (items.biblionumber=biblio.biblionumber)
WHERE (issues.issuedate BETWEEN DATE_SUB(CURDATE(), INTERVAL 7 DAY) AND CURDATE() 
      AND issues.branchcode = <<Issuing branch|branches>>)
ORDER BY borrowers.surname ASC, issues.date_due ASC

Number of Checkouts by Branch

  • Developer: Nicole C. Engard, ByWater Solutions
  • Module: Circulation
  • Purpose: Statistical Count by month of number of checkouts made by each branch all in one report
  • Status: Complete


  SELECT branch, month(datetime) AS month, year(datetime) AS year, count(datetime) AS count 
  FROM statistics 
  WHERE type LIKE 'issue' 
  GROUP BY branch, year, month 
  ORDER BY year, month DESC, branch ASC


Not Circulating Items (Date Specific)

  • Developer: Bev Church, Joe Tholen
  • Module: Circulation
  • Purpose: List items not circulated in specific date range, by shelf location (weeding tool)
  • Status: Needs Work


  SELECT barcode, homebranch AS 'branch', itemcallnumber, title 
  FROM biblio, items 
  WHERE items.biblionumber = biblio.biblionumber AND homebranch = <<Home branch|branches>> AND location = <<Shelving location|LOC>> AND itemnumber NOT IN 
  (SELECT itemnumber FROM issues) UNION 
  (SELECT barcode, homebranch AS 'branch', itemcallnumber, title 
  FROM biblio, items 
  WHERE items.biblionumber = biblio.biblionumber AND homebranch = <<Home branch again|branches>> AND location = <<Shelving location again|LOC>> AND itemnumber NOT IN 
  (SELECT itemnumber FROM old_issues WHERE date(issuedate) BETWEEN <<Checked out BETWEEN (yyyy-mm-dd)>> AND <<and (yyyy-mm-dd)>>) ) 
  ORDER BY itemcallnumber, barcode

Non Circulating Items

  • Developer: Nicole C. Engard, ByWater Solutions
  • Module: Circulation
  • Purpose: List items that have never circulated
  • Status: Complete


SELECT b.title, i.itemcallnumber, i.barcode 
FROM items i 
LEFT JOIN issues 
USING (itemnumber) 
LEFT JOIN biblio b 
USING (biblionumber) 
WHERE i.itemnumber NOT IN (SELECT issues.itemnumber FROM issues) 
UNION 
(SELECT b.title, i.itemcallnumber,i.barcode 
FROM items i 
LEFT JOIN issues 
USING (itemnumber) 
LEFT JOIN biblio b
USING (biblionumber) 
WHERE i.itemnumber NOT IN (SELECT old_issues.itemnumber FROM old_issues))


Non Circulating Items in X Years

  • Developer: Marion J. Makarewicz and Nicole C. Engard, ByWater Solutions
  • Module: Circulation
  • Purpose: List items that have not circulated in X Years
  • Status: Complete


SELECT b.title, b.author, b.copyrightdate, i.itemcallnumber,
       i.barcode, i.datelastborrowed, i.issues AS totalcheckouts,
       i.dateaccessioned
FROM items i
LEFT JOIN issues
USING (itemnumber)
LEFT JOIN biblio b
USING (biblionumber)
WHERE i.itemnumber NOT IN (SELECT issues.itemnumber FROM issues) 
      AND  YEAR(NOW())-YEAR(i.datelastborrowed) > <<Years NOT circulated>>
UNION 
SELECT b.title, b.author, b.copyrightdate, i.itemcallnumber,
       i.barcode, i.datelastborrowed, i.issues AS totalcheckouts,
       i.dateaccessioned
FROM items i
LEFT JOIN issues
USING (itemnumber)
LEFT JOIN biblio b
USING (biblionumber)
WHERE i.itemnumber NOT IN (SELECT old_issues.itemnumber FROM old_issues) 
      AND YEAR(NOW())-YEAR(i.datelastborrowed) > <<Years NOT circulated (again)>>

Patrons w/ Books Due Tomorrow

  • Developer: Nicole C. Engard, ByWater Solutions, Koha List
  • Module: Circulation
  • Purpose: List patrons with books due tommorrow
  • Status: Complete


  SELECT borrowers.cardnumber, borrowers.surname, borrowers.firstname, issues.date_due, items.barcode, biblio.title, biblio.author
  FROM borrowers 
  LEFT JOIN issues ON (issues.borrowernumber=borrowers.borrowernumber) 
  LEFT JOIN items ON (issues.itemnumber=items.itemnumber) 
  LEFT JOIN biblio ON (biblio.biblionumber=items.biblionumber) 
  WHERE issues.date_due = DATE_ADD(curdate(), INTERVAL 1 DAY) 
  ORDER BY borrowers.surname ASC

Transfers by Other Branches

  • Developer: Joe Tholen
  • Module: Circulation
  • Purpose: List total transfers from other branches, by branches, by month
  • Status: Be warned this is done over the previous YEAR. Not for the current one. To combine with ILL stats


  SELECT frombranch, monthname(datesent) month,COUNT(*) 
  FROM branchtransfers WHERE tobranch=<<Transferred TO|branches>> AND YEAR(datesent)=YEAR(NOW())-1 
  GROUP BY month

Transfers as Interlibrary Loans

  • Developer: Sharon Moreland
  • Module: Circulation
  • Purpose: Counts transfers of Library A's materials to a library that is not Library A
  • Status: This is done over the previous YEAR. Not for the current one. ILL Loans.


SELECT items.homebranch, COUNT(*) 
FROM branchtransfers 
LEFT JOIN items ON (branchtransfers.itemnumber=items.itemnumber) 
WHERE (items.homebranch != branchtransfers.tobranch) 
AND (branchtransfers.frombranch != branchtransfers.tobranch) AND YEAR(datesent)=YEAR(NOW())-1 
GROUP BY items.homebranch

Transfers as Interlibrary Borrows

  • Developer: Sharon Moreland
  • Module: Circulation
  • Purpose: Counts when materials that are not Library A's are transferred to Library A.
  • Status: This is done over the previous YEAR. Not for the current one. ILL Borrows.


SELECT branchtransfers.tobranch, COUNT(*) 
FROM branchtransfers 
LEFT JOIN items ON (branchtransfers.itemnumber=items.itemnumber) 
WHERE (branchtransfers.tobranch != items.homebranch) 
AND (branchtransfers.tobranch != branchtransfers.frombranch) AND YEAR(datesent)=YEAR(NOW())-1 
GROUP BY branchtransfers.tobranch

Materials Checked out to Other Libraries

  • Developer: Scotty Zollars
  • Module: Circulation
  • Purpose: List interlibrary loan materials check out to other libraries, by month
  • Status: Be warned this is done over the previous YEAR. Not for the current one. ILL record keeping


SELECT  monthname(datesent) month,COUNT(*) 
  FROM branchtransfers WHERE frombranch=<<Transferred FROM|branches>> AND YEAR(datesent)=YEAR(NOW())-1 
  GROUP BY month ORDER BY month(datesent)


List that totals the circulation of each Dewey section, F, and periodicals, by month

  • Developer: Joe Atzberger
  • Module: Statistical (Circulation, Reports)
  • Purpose: List that totals the circulation of each Dewey section, F, and periodicals, by month
  • Status: Complete
  SELECT DATE(datetime) AS date, substring(itemcallnumber,1,1) AS 'Call# range', count(*) AS count  
  FROM statistics 
  LEFT JOIN items USING (itemnumber) 
  WHERE statistics.type IN ('issue', 'renew') AND YEAR(datetime) = <<Year (yyyy)>> AND MONTH(datetime) = <<Month (mm)>>  
  GROUP BY DATE(datetime), substring(itemcallnumber,1,1)

List that totals the circulation of each Dewey section, F, and periodicals, by day

  • Developer: Joe Atzberger, Scotty Zollars
  • Module: Statistical (Circulation, Reports)
  • Purpose: List that totals the circulation of each Dewey section, F, and periodicals, by day
  • Status: Complete
  SELECT DATE(datetime) AS date, substring(itemcallnumber,1,1) AS 'Call# range', count(*) AS count  
  FROM statistics 
  LEFT JOIN items USING (itemnumber) 
  WHERE statistics.type IN ('issue', 'renew') AND YEAR(datetime) = <<Year (yyyy)>> AND MONTH(datetime) = <<Month (mm)>> AND DAY(datetime) = <<Day (dd)>>
  GROUP BY DATE(datetime), substring(itemcallnumber,1,1)

Overdue materials

  • Developer: Sharon Moreland
  • Module: Circulation
  • Purpose: Overdue materials
  • Status: Complete


SELECT borrowers.surname, borrowers.firstname, borrowers.phone, borrowers.cardnumber, 
       borrowers.address, borrowers.city, borrowers.zipcode, issues.date_due, 
       (TO_DAYS(curdate())-TO_DAYS( date_due)) AS 'days overdue', items.itype, 
       items.itemcallnumber, items.barcode, items.homebranch, biblio.title, biblio.author 
FROM borrowers 
LEFT JOIN issues ON (borrowers.borrowernumber=issues.borrowernumber) 
LEFT JOIN items ON (issues.itemnumber=items.itemnumber) 
LEFT JOIN biblio ON (items.biblionumber=biblio.biblionumber) 
WHERE (TO_DAYS(curdate())-TO_DAYS(date_due)) > '30' AND issues.branchcode = <<Issuing branch|branches>>
ORDER BY borrowers.surname ASC, issues.date_due ASC

Long Overdues

  • Developer: Nicole C. Engard, ByWater Solutions
  • Module: Circulation
  • Purpose: Items that are long overdue
  • Status: Complete


SELECT borrowers.surname, borrowers.firstname, borrowers.phone, borrowers.cardnumber, 
       issues.date_due, biblio.title, biblio.author, items.itemcallnumber, items.barcode, 
       items.homebranch, (TO_DAYS(curdate())-TO_DAYS( date_due)) AS 'days overdue' 
FROM borrowers 
LEFT JOIN issues ON (borrowers.borrowernumber=issues.borrowernumber) 
LEFT JOIN items ON (issues.itemnumber=items.itemnumber) 
LEFT JOIN biblio ON (items.biblionumber=biblio.biblionumber) 
WHERE (TO_DAYS(curdate())-TO_DAYS(date_due)) > <<Due date more than (enter IN days)>> 
AND (TO_DAYS(curdate())-TO_DAYS(date_due)) < <<Due date less than (enter IN days)>>
ORDER BY borrowers.surname ASC, issues.date_due ASC

Count of Circ by Alpha Call Number Prefix

  • Developer: Jared Camins-Esakov and Nicole C. Engard, ByWater Solutions
  • Module: Circulation
  • Purpose: A statistical report showing how many items with a specific alphabetical prefix have circulated in a month
  • Status: Complete
SELECT SUBSTRING_INDEX(itemcallnumber, ' ', 1) AS 'Call# range', count(*) AS count 
FROM statistics 
LEFT JOIN items USING (itemnumber) 
WHERE statistics.type IN ('issue', 'renew') AND YEAR(datetime) = <<Year (yyyy)>> AND 
      MONTH(datetime) = <<Month (mm)>> AND SUBSTRING_INDEX(itemcallnumber, ' ', 1) RLIKE '[a-z]' 
GROUP BY SUBSTRING_INDEX(itemcallnumber, ' ', 1)

Count of Circ by Call Number Prefix

  • Developer: Jared Camins-Esakov
  • Module: Circulation
  • Purpose: A statistical report showing how many items with any prefix (meaning the letters/numbers before the first space) have circulated in a month
  • Status: Complete
SELECT SUBSTRING_INDEX(itemcallnumber, ' ', 1) AS 'Call# range', count(*) AS count 
FROM statistics 
LEFT JOIN items USING (itemnumber) 
WHERE statistics.type IN ('issue', 'renew') AND YEAR(datetime) = <<Year (yyyy)>> AND 
      MONTH(datetime) = <<Month (mm)>>  
GROUP BY SUBSTRING_INDEX(itemcallnumber, ' ', 1)

Top 10 Circulating Books

  • Developer: Nicole C. Engard, ByWater Solutions
  • Module: Circulation
  • Purpose: Top 10 circulating books for the last 6 months
  • Status: Complete
SELECT count(statistics.datetime) AS circs, biblio.title, biblio.author,
       items.ccode 
FROM statistics 
JOIN items ON (items.itemnumber=statistics.itemnumber) 
LEFT JOIN biblio ON (biblio.biblionumber=items.biblionumber) 
WHERE DATE(statistics.datetime) > DATE_SUB(CURRENT_DATE(),INTERVAL 6 MONTH) 
      AND DATE(statistics.datetime)<=CURRENT_DATE() AND 
      statistics.itemnumber IS NOT NULL 
GROUP BY biblio.biblionumber 
ORDER BY circs DESC 
LIMIT 10

Low Circulating Items

  • Developer: Jared Camins-Esakov, ByWater Solutions
  • Module: Circulation
  • Purpose: A list of materials (title, author, barcode, call number) that have only gone out X number of times during X dates, from X item type
  • Status: Complete
SELECT biblio.title, biblio.author, items.barcode, items.itemcallnumber 
FROM old_issues 
LEFT JOIN items ON (items.itemnumber=old_issues.itemnumber) 
LEFT JOIN biblio ON (biblio.biblionumber=items.biblionumber) 
WHERE old_issues.issuedate BETWEEN <<Between (yyyy-mm-dd)>> AND <<and (yyyy-mm-dd)>>
AND items.itype=<<Item Type Code>> 
GROUP BY old_issues.itemnumber HAVING COUNT(old_issues.issuedate) = <<Total Issues>> 
ORDER BY biblio.title ASC

Overdues at a Specific Branch

  • Developer: Nicole C. Engard, ByWater Solutions
  • Module: Circulation
  • Purpose: Patron and item info for books that are overdue from one specific branch.
  • Status: Complete
SELECT borrowers.cardnumber, borrowers.surname, borrowers.firstname, 
       borrowers.phone, borrowers.address, borrowers.city,  
       borrowers.zipcode, issues.issuedate, issues.date_due, 
       (TO_DAYS(curdate())-TO_DAYS( date_due)) AS 'days overdue', biblio.title, 
       items.barcode 
FROM borrowers 
LEFT JOIN issues ON (borrowers.borrowernumber=issues.borrowernumber) 
LEFT JOIN items ON (issues.itemnumber=items.itemnumber) 
LEFT JOIN biblio ON (items.biblionumber=biblio.biblionumber) 
WHERE issues.branchcode = <<Branch Code>> AND 
      (TO_DAYS(curdate())-TO_DAYS( date_due)) > 0 
ORDER BY borrowers.surname ASC, issues.date_due ASC

Items with no Circs in a specific timeframe

  • Developer: Nicole C. Engard and Ian Walls, ByWater Solutions
  • Module: Circulation
  • Purpose: Titles that haven't checked out in a specific period of time
  • Status: Complete
SELECT biblio.title, biblio.author, items.itemcallnumber, items.barcode 
FROM biblio JOIN items USING (biblionumber) 
WHERE items.itype = <<Item type|itemtypes>> AND itemnumber NOT IN 
     (SELECT DISTINCT itemnumber 
      FROM statistics 
      WHERE type = 'issue' AND 
      datetime BETWEEN <<Between (yyyy-mm-dd)>> AND <<and (yyyy-mm-dd)>>)

Checkout by Shelving Location

  • Developer: Nicole C. Engard, ByWater Solutions
  • Module: Circulation
  • Purpose: A count of checkouts by shelving location at a specific branch in a specific timeframe.
  • Status: Complete
SELECT items.location, count(statistics.datetime) AS count 
FROM items LEFT JOIN statistics USING (itemnumber) 
WHERE date(statistics.datetime) BETWEEN <<Date BETWEEN (yyyy-mm-dd)>> AND <<and (yyyy-mm-dd)>> 
      AND statistics.type='issue' AND statistics.branch=<<Pick your branch|branches>> 
GROUP BY items.location 
ORDER BY items.location ASC

Checkins by Shelving Location

  • Developer: Nicole C. Engard, ByWater Solutions
  • Module: Circulation
  • Purpose: A count of checkins by shelving location at a specific branch in a specific timeframe.
  • Status: Complete


SELECT items.location, count(statistics.datetime) AS count 
FROM items LEFT JOIN statistics USING (itemnumber) 
WHERE date(statistics.datetime) BETWEEN <<Date BETWEEN (yyyy-mm-dd)>> AND <<and (yyyy-mm-dd)>> 
      AND statistics.type='return' AND statistics.branch=<<Pick your branch|branches>> 
GROUP BY items.location 
ORDER BY items.location ASC


Renewals by Shelving Location

  • Developer: Nicole C. Engard, ByWater Solutions
  • Module: Circulation
  • Purpose: A count of renewals by shelving location at a specific branch in a specific timeframe.
  • Status: Complete
SELECT items.location, count(statistics.datetime) AS count 
FROM items LEFT JOIN statistics USING (itemnumber) 
WHERE date(statistics.datetime) BETWEEN <<Date BETWEEN (yyyy-mm-dd)>> AND <<and (yyyy-mm-dd)>> 
      AND statistics.type='renew' AND statistics.branch=<<Pick your branch|branches>> 
GROUP BY items.location 
ORDER BY items.location ASC


Local Use by Shelving Location

  • Developer: Nicole C. Engard, ByWater Solutions
  • Module: Circulation
  • Purpose: A count of in house use by shelving location at a specific branch in a specific timeframe.
  • Status: Complete
SELECT items.location, count(statistics.datetime) AS count 
FROM items LEFT JOIN statistics USING (itemnumber) 
WHERE date(statistics.datetime) BETWEEN <<Date BETWEEN (yyyy-mm-dd)>> AND <<and (yyyy-mm-dd)>> 
      AND statistics.type='localuse' AND statistics.branch=<<Pick your branch|branches>> 
GROUP BY items.location 
ORDER BY items.location ASC


Circ Transaction Counts

  • Developer: Nicole C. Engard, ByWater Solutions
  • Module: Circulation
  • Purpose: A count of circulation transactions at a specific branch in a specific timeframe.
  • Status: Complete
SELECT type AS 'Transaction type', count(datetime) AS count 
FROM statistics 
WHERE date(datetime) BETWEEN <<Date BETWEEN (yyyy-mm-dd)>> AND <<and (yyyy-mm-dd)>> 
      AND branch==<<Pick your branch|branches>> 
GROUP BY type 
ORDER BY type ASC

Checkouts & Renewal Counts by Call Number

  • Developer: VOKAL
  • Module: Circulation
  • Purpose: A count of checkouts and renewals (and a total of both) in a specific month.
  • Status: Complete
SELECT LEFT(i.itemcallnumber,3) AS "Call No.", 
       SUM(IF(s.type = 'issue', 1, 0)) AS Checkout, 
       SUM(IF(s.type = 'renew', 1, 0)) AS Renewal, 
       SUM(IF((s.type = 'renew' OR s.type='issue'), 1, 0)) AS TOTAL
FROM items i 
LEFT JOIN statistics s 
ON i.itemnumber=s.itemnumber
WHERE year(s.datetime)=<<Year (yyyy)>> AND month(s.datetime)=<<Month (mm)>> 
      AND i.homebranch=<<Branch|branches>> 
GROUP BY LEFT(i.itemcallnumber,3) 
WITH ROLLUP

Detailed report of long-overdues charged-off in the last week

  • Developer: D Ruth Bavousett, ByWater Solutions
  • Module: Circulation
  • Purpose: List all borrowers/items that have been marked as Lost--and remain unpaid--from the last seven days.
  • Status: Completed
SELECT cardnumber AS "Borrower Barcode",
               surname AS "Last Name", 
               firstname AS "First Name", 
               ROUND(amountoutstanding,2) AS "Amount Due", 
               biblio.title AS "Title", 
               author AS "Author",
               barcode AS "Item Barcode"
   FROM accountlines
   JOIN borrowers USING (borrowernumber) LEFT JOIN items USING (itemnumber) JOIN biblio USING (biblionumber) 
WHERE accounttype = "L" AND date > DATE_SUB(CURRENT_DATE(),INTERVAL 7 DAY)


Average Checkouts

  • Developer: Katrin Fischer and Nicole C. Engard, ByWater Solutions
  • Module: Statistical (Circulation)
  • Purpose: Average number of checkouts in time period
  • Status: Complete
SELECT avg(counter) AS average 
FROM 
   (SELECT borrowernumber, date(datetime) AS ckodate, 
           count(*) AS counter 
    FROM statistics 
    WHERE date(datetime) BETWEEN <<Checked out BETWEEN (yyyy-mm-dd>> 
          AND <<and (yyyy-mm-dd)>> AND type='issue'
    GROUP BY borrowernumber, ckodate) 
temp

Catalog/Bibliographic Reports

Accession Register Sorted by Barcode Number Report

  • Developer: Ata ur Rehman (ata.rehman@gmail.com)
  • Module: Catalog
  • Purpose: To create an Accession Register Sorted by Barcode Number Report
  • Status: Complete
  SELECT items.barcode, biblio.author, biblio.title, items.itemcallnumber, 
  items.holdingbranch, biblioitems.isbn, biblioitems.pages, biblioitems.size, 
  biblioitems.place, biblio.copyrightdate 
  FROM items 
  LEFT JOIN biblioitems ON (items.biblioitemnumber=biblioitems.biblioitemnumber) 
  LEFT JOIN biblio ON (biblioitems.biblionumber=biblio.biblionumber) 
  ORDER BY LPAD(items.barcode,30,' ') ASC

Total collection size

  • Developer: Sharon Moreland
  • Module: Catalog
  • Purpose: Total collection size
  • Status: Complete
  SELECT count(i.biblionumber) AS added, i.itype, i.homebranch, i.location 
  FROM items i 
  WHERE i.dateaccessioned < <<Acquired before (yyyy-mm-dd)>>  
  GROUP BY i.homebranch,i.itype,i.location 
  ORDER BY i.homebranch,i.itype,i.location ASC

Total Collection Size by Date

  • Developer: Nicole C. Engard, ByWater Solutions
  • Module: Catalog
  • Purpose: Total collection size by item type and branch by a specific date (for example first of the month)
  • Status: Complete
SELECT COALESCE(homebranch,'*GRAND TOTAL*') AS homebranch, 
       IFNULL(itype, "") AS itype, count(itype) AS count 
FROM items 
WHERE dateaccessioned < <<Added before (yyyy-mm-dd)>> 
GROUP BY homebranch, itype 
WITH rollup

URLs in Catalog

  • Developer: Lenora Oftedahl
  • Module: Catalog
  • Purpose: URLs in Catalog
  • Status: Needs work as I only want the URLs, not all barcodes
  SELECT  items.barcode,biblioitems.url 
  FROM items LEFT JOIN biblioitems ON (items.biblioitemnumber=biblioitems.biblioitemnumber) 
  LEFT JOIN biblio ON (biblioitems.biblionumber=biblio.biblionumber)   
  WHERE items.homebranch=<<Home branch|branches>>

Null Item Type

  • Developer: Sharon Moreland
  • Module: Catalog
  • Purpose: Null Item Type
  • Status: Complete
  SELECT  items.dateaccessioned,items.ccode,items.itemcallnumber,items.itype,biblio.author,biblio.title, biblio.copyrightdate 
  FROM items 
  LEFT JOIN biblioitems ON (items.biblioitemnumber=biblioitems.biblioitemnumber) 
  LEFT JOIN biblio ON (biblioitems.biblionumber=biblio.biblionumber)  
  WHERE items.itype IS NULL AND items.homebranch=<<Home branch|branches>>

Null Barcodes

  • Developer: Rachel Hollis
  • Module: Catalog
  • Purpose: Null Barcodes
  • Status: Complete
  SELECT items.dateaccessioned,items.ccode,items.itemcallnumber,items.itype,biblio.author,biblio.title, biblio.copyrightdate 
  FROM items
  LEFT JOIN biblioitems ON (items.biblioitemnumber=biblioitems.biblioitemnumber)
  LEFT JOIN biblio ON (biblioitems.biblionumber=biblio.biblionumber)
  WHERE Barcode IS NULL

Items with "X" CCode

  • Developer: Sharon Moreland
  • Module: Catalog
  • Purpose: Items with "X" CCode
  • Status: Complete
  SELECT  items.dateaccessioned,items.ccode,items.itemcallnumber,items.itype,biblio.author,biblio.title, biblio.copyrightdate 
  FROM items 
  LEFT JOIN biblioitems ON (items.biblioitemnumber=biblioitems.biblioitemnumber) 
  LEFT JOIN biblio ON (biblioitems.biblionumber=biblio.biblionumber)  
  WHERE items.homebranch=<<Home branch|branches>> AND items.ccode=<<Collection|CCODE>> 
  ORDER BY items.dateaccessioned DESC

Items with "X" & "Y" ITypes

  • Developer: Sharon Moreland
  • Module: Catalog
  • Purpose: Items with "X" & "Y" ITypes
  • Status: Complete
  SELECT  items.dateaccessioned,items.itype,items.itemcallnumber,items.barcode,biblio.author,biblio.title, biblio.copyrightdate 
  FROM items 
  LEFT JOIN biblioitems ON (items.biblioitemnumber=biblioitems.biblioitemnumber) 
  LEFT JOIN biblio ON (biblioitems.biblionumber=biblio.biblionumber) 
  WHERE (items.homebranch=<<Home branch|branches>> AND items.itype=<<Item type|itemtypes>>) 
        OR (items.homebranch=<<Second home branch|branches>> AND items.itype=<<Second item type|itemtypes>>) 
  ORDER BY items.dateaccessioned DESC

Call Numbers

  • Developer: Sharon Moreland
  • Module: Catalog
  • Purpose: Call Numbers
  • Status: Complete
  SELECT items.itype,items.itemcallnumber,items.barcode,biblio.title,biblio.copyrightdate 
  FROM items 
  LEFT JOIN biblioitems ON (items.biblioitemnumber=biblioitems.biblioitemnumber) 
  LEFT JOIN biblio ON (biblioitems.biblionumber=biblio.biblionumber) 
  WHERE items.homebranch=<<Home branch|branches>> AND items.itemcallnumber LIKE <<Call number LIKE (USE % FOR wildcard)>> 
  ORDER BY items.itemcallnumber ASC

Complete Shelf list

  • Developer: Sharon Moreland
  • Module: Catalog
  • Purpose: Complete Shelf list
  • Status: Complete
  SELECT  items.price,items.replacementprice,biblio.title,biblio.author,items.itemcallnumber 
  FROM items 
  LEFT JOIN biblioitems ON (items.biblioitemnumber=biblioitems.biblioitemnumber) 
  LEFT JOIN biblio ON (biblioitems.biblionumber=biblio.biblionumber) 
  WHERE items.homebranch=<<Home branch|branches>> 
  ORDER BY items.itemcallnumber ASC

All Barcodes

  • Developer: Sharon Moreland
  • Module: Catalog
  • Purpose: All Barcodes
  • Status: Complete
  SELECT items.barcode,items.location,biblio.title,items.itemcallnumber 
  FROM items 
  LEFT JOIN biblioitems ON (items.biblioitemnumber=biblioitems.biblioitemnumber) 
  LEFT JOIN biblio ON (biblioitems.biblionumber=biblio.biblionumber)  
  WHERE items.homebranch=<<Home branch|branches>>

New Bib Records

  • Developer: Nicole C. Engard, ByWater Solutions
  • Module: Catalog
  • Purpose: List new bibs in specific time frame
  • Status: Complete
SELECT monthname(datecreated) AS month, year(datecreated) AS year, count(biblionumber) AS count 
FROM biblio 
WHERE datecreated BETWEEN <<Between (yyyy-mm-dd)>> AND <<and (yyyy-mm-dd)>> 
GROUP BY year(datecreated), month(datecreated)

Bibs Marked On Order

  • Developer: Nicole C. Engard, ByWater Solutions
  • Module: Catalog
  • Purpose: List all the bib records that have been marked as on order
  • Status: Complete
SELECT biblio.title, biblio.author, items.barcode, 
       items.itemcallnumber, biblio.copyrightdate 
FROM biblio 
LEFT JOIN items 
ON (items.biblionumber=biblio.biblionumber) 
WHERE items.notforloan = '-1' 
ORDER BY biblio.title

List new items

  • Developer: Sharon Moreland
  • Module: Catalog
  • Purpose: List new items
  • Status: Complete
  SELECT items.dateaccessioned,biblio.title,items.itemcallnumber 
  FROM items LEFT JOIN biblioitems ON (items.biblioitemnumber=biblioitems.biblioitemnumber) 
  LEFT JOIN biblio ON (biblioitems.biblionumber=biblio.biblionumber) 
  WHERE DATE (items.dateaccessioned)  BETWEEN <<Between (yyyy-mm-dd)>> AND <<and (yyyy-mm-dd)>> AND items.homebranch=<<Home branch|branches>> 
  ORDER BY items.itemcallnumber ASC

Another new items report

  • Developer: Nicole C. Engard, ByWater Solutions
  • Module: Catalog
  • Purpose: List new items between specific dates
  • Status: Complete
SELECT monthname(timestamp) AS month, year(timestamp) AS year, count(itemnumber) AS count 
FROM items 
WHERE timestamp BETWEEN <<Between (yyyy-mm-dd)>> AND <<and (yyyy-mm-dd)>>
GROUP BY year(timestamp), month(timestamp)

List of Items added to catalog in last 30 days

  • Developer: Nora Blake
  • Module: Catalog
  • Purpose: List of Items added to catalog in last 30 days (includes bibliographic info)
  • Status: Complete
  SELECT items.dateaccessioned,items.itemcallnumber,biblio.title,biblio.author 
  FROM items 
  LEFT JOIN biblioitems ON (items.biblioitemnumber=biblioitems.biblioitemnumber) 
  LEFT JOIN biblio ON (biblioitems.biblionumber=biblio.biblionumber) 
  WHERE items.homebranch=<<Home branch|branches>> AND DATE_SUB(CURDATE(),INTERVAL 30 DAY) <= items.dateaccessioned 
  ORDER BY biblio.title ASC

Count of all items

  • Developer: Michael Hafen
  • Module: Catalog
  • Purpose: Count of all items
  • Status: Complete
  SELECT COUNT(barcode) AS Count FROM items WHERE barcode <> '' AND barcode IS NOT NULL

Count of all items by Item Type

  • Developer: Michael Hafen
  • Module: Catalog
  • Purpose: Count of all items by Item Type
  • Status: Complete
  SELECT itype AS 'Item Type',COUNT(barcode) AS Count FROM items WHERE barcode <> ''
  AND barcode IS NOT NULL GROUP BY itype

Count of all items and broken down by branch

  • Developer: Zachary Spalding, SENYLRC
  • Module: Catalog
  • Purpose: Count of all items by Item and broken down by branch
  • Status: Complete
SELECT items.homebranch,branches.branchname, count(items.itemnumber) AS items FROM items,branches WHERE items.homebranch=branches.branchcode GROUP BY homebranch ORDER BY homebranch ASC

Count of all titles

  • Developer: Michael Hafen
  • Module: Catalog
  • Purpose: Count of all titles
  • Status: Complete
  SELECT COUNT(biblionumber) AS Count FROM biblio

Count of all Bibs and Items per Branch

  • Developer: Nicole C. Engard, ByWater Solutions
  • Module: Catalog
  • Purpose: A count of all unique bibs and total items held at each branch
  • Status: Complete
SELECT homebranch, count(DISTINCT biblionumber) AS bibs, 
       count(itemnumber) AS items 
FROM items 
GROUP BY homebranch 
ORDER BY homebranch ASC


Statistical Count of total number of items held by each branch

  • Developer: Nicole C. Engard, ByWater Solutions
  • Module: Catalog
  • Purpose: Statistical Count of total number of items held by each branch all in one report
  • Status: Complete
  SELECT homebranch,count(itemnumber) AS items 
  FROM items 
  GROUP BY homebranch 
  ORDER BY homebranch ASC

All bibs without items

  • Developer: Nicole C. Engard, ByWater Solutions
  • Module: Catalog
  • Purpose: All bibs without items
  • Status: Complete
  SELECT biblio.biblionumber, biblio.title 
  FROM biblio 
  LEFT JOIN items ON biblio.biblionumber = items.biblionumber 
  WHERE items.itemnumber IS NULL

All bibs where last item deleted

  • Developer: Nicole C. Engard, ByWater Solutions
  • Module: Catalog
  • Purpose: All bibs without items where the last item was deleted
  • Status: Complete
SELECT b.biblionumber, b.title, b.author
FROM biblio b
LEFT JOIN items i USING (biblionumber) 
WHERE i.itemnumber IS NULL 
      AND b.biblionumber IN (SELECT biblionumber FROM deleteditems)
GROUP BY b.biblionumber

Weeding tool

  • Developer: Kathy Rippel
  • Module: Catalog
  • Purpose: Weeding tool, we call this the SuperWeeder because it includes all sorts of data to help in decision making
  • Status: Complete
SELECT CONCAT( '<a href=\"/cgi-bin/koha/cataloguing/additem.pl?biblionumber=', biblio.biblionumber,'\">', 
       items.barcode, '</a>' ) AS 'Barcode', items.itemcallnumber, biblio.title, 
       biblio.copyrightdate AS 'Copyright', items.dateaccessioned AS 'Accessioned', items.itype, 
       items.issues, items.renewals, (IFNULL(items.issues, 0)+IFNULL(items.renewals, 0)) AS Total_Circ, 
       items.datelastborrowed, items.itemlost, items.onloan, items.damaged, items.itemnotes
FROM items
LEFT JOIN biblioitems ON (items.biblioitemnumber=biblioitems.biblioitemnumber) 
LEFT JOIN biblio ON (biblioitems.biblionumber=biblio.biblionumber)
WHERE items.itype= <<Item type code|itemtypes>> AND items.holdingbranch=<<Branch code|branches>> 
      AND items.itemcallnumber BETWEEN <<Call number between>> AND <<and>>
ORDER BY items.itemcallnumber

Inventory Report

  • Developer: Nicole C. Engard, ByWater Solutions
  • Module: Catalog
  • Purpose: Find all items that haven't been seen since a specific date
  • Status: Complete
SELECT b.title, i.barcode, i.itemcallnumber, 
      IF(i.onloan IS NULL, '', 'checked out') AS onloan
 FROM biblio b
 LEFT JOIN items i USING (biblionumber)
 WHERE datelastseen < <<Last seen before (yyyy-mm-dd)>> 
                 AND i.homebranch=<<Home branch|branches>>
 ORDER BY datelastseen DESC, i.itemcallnumber ASC

Items added by Collection

  • Developer: Katrin Fischer and Nicole C. Engard, ByWater Solutions
  • Module: Catalog
  • Purpose: Count of items added by collection in a specific date range
  • Status: Complete
SELECT count(ccode), ccode AS collection
FROM (
SELECT ccode, timestamp FROM items
UNION ALL
SELECT ccode, timestamp FROM deleteditems
)
AS itemsadded
WHERE date(timestamp) BETWEEN
<<Added BETWEEN (yyyy-mm-dd)>> AND <<and (yyyy-mm-dd)>>
GROUP BY ccode

Damaged Items with Title

  • Developer: Jane Wagner, PTFS
  • Module: Catalog
  • Purpose: Damaged Items with Title
  • Status: Complete
SELECT items.damaged, items.itemcallnumber, items.barcode, biblio.title, biblio.author 
FROM items 
INNER JOIN biblio ON items.biblionumber = biblio.biblionumber 
WHERE items.damaged = True ORDER BY biblio.title ASC

Count by Call Number

  • Developer: Jane Wagner, PTFS
  • Module: Catalog
  • Purpose: Count by Call Number
  • Status: Complete
SELECT count(items.itemcallnumber) AS 'Number of Items', items.itemcallnumber 
FROM items 
GROUP BY items.itemcallnumber 
ORDER BY items.itemcallnumber ASC

Count by Call Number for items added last month

  • Developer: Jane Wagner, PTFS
  • Module: Catalog
  • Purpose: Count by Call Number for items added last month
  • Status: Complete
SELECT count(items.itemcallnumber), items.itemcallnumber 
FROM items 
WHERE items.dateaccessioned >= concat(date_format(LAST_DAY(now() - interval 1 month),'%Y-%m-'),'01') AND items.dateaccessioned <= LAST_DAY(now() - interval 1 month) 
GROUP BY items.itemcallnumber 
ORDER BY items.itemcallnumber ASC

Previous Month Items Created

  • Developer: Jane Wagner, PTFS
  • Module: Catalog
  • Purpose: Previous Month Items Created
  • Status: Complete
SELECT count(items.itemnumber) AS ItemsCreated 
FROM items 
WHERE items.dateaccessioned >= concat(date_format(LAST_DAY(now() - interval 1 month),'%Y-%m-'),'01') AND items.dateaccessioned <= LAST_DAY(now() - interval 1 month)

Previous Month Items Deleted

  • Developer: Jane Wagner, PTFS
  • Module: Catalog
  • Purpose: Previous Month Items Deleted
  • Status: Complete
SELECT count(deleteditems.itemnumber) AS ItemsDeleted 
FROM deleteditems 
WHERE deleteditems.timestamp LIKE concat(date_format(LAST_DAY(now() - interval 1 month),'%Y-%m-%'))

Previous Month Items Created--by item type

  • Developer: Jane Wagner, PTFS
  • Module: Catalog
  • Purpose: Previous Month Items Created--by item type (The total number of rows shown is misleading -- It matches the first item type total. An empty item type column means unknown item type. Add all the entries for the complete total.)
  • Status: Complete
SELECT items.itype AS ItemType, count(items.itemnumber) AS ItemsCreated 
FROM items 
WHERE (items.dateaccessioned >= concat(date_format(LAST_DAY(now() - interval 1 month),'%Y-%m-'),'01') AND items.dateaccessioned <= LAST_DAY(now() - interval 1 month))  
GROUP BY items.itype

Previous Month Items Deleted--by item type

  • Developer: Jane Wagner, PTFS
  • Module: Catalog
  • Purpose: Previous Month Items Deleted--by item type (The total number of rows shown is misleading -- It matches the first item type total. An empty item type column means unknown item type. Add all the entries for the complete total.)
  • Status: Complete
SELECT deleteditems.itype AS ItemType, count(deleteditems.itemnumber) AS ItemsDeleted 
FROM deleteditems 
WHERE (deleteditems.timestamp LIKE concat(date_format(LAST_DAY(now() - interval 1 month),'%Y-%m-%'))) 
GROUP BY deleteditems.itype

Withdrawn Items (w/ details)

  • Developer: Jane Wagner, PTFS
  • Module: Catalog
  • Purpose: Withdrawn Items
  • Status: Complete
SELECT biblio.title,biblio.author,items.itemcallnumber,items.barcode,items.datelastborrowed, items.wthdrawn 
FROM items 
LEFT JOIN biblioitems ON (items.biblioitemnumber=biblioitems.biblioitemnumber) 
LEFT JOIN biblio ON (biblioitems.biblionumber=biblio.biblionumber) 
WHERE items.wthdrawn != 0 
ORDER BY biblio.title ASC

Withdrawn Items (barcodes only)

  • Developer: Nicole C. Engard, ByWater Solutions
  • Module: Catalog
  • Purpose: Barcodes of items marked as withdrawn (best used for batch deleting)
  • Status: Complete
SELECT items.barcode
FROM items
WHERE items.wthdrawn != 0 
ORDER BY items.barcode ASC

List of URL's from 856

  • Developer: LibLime provided to David Schuster
  • Module: Catalog
  • Purpose: List of URL's from 856
  • Status: Complete
SELECT biblio.biblionumber, SUBSTRING(biblioitems.marcxml, LOCATE('<subfield code="u">', 
       biblioitems.marcxml, LOCATE('<datafield tag="856"', biblioitems.marcxml)+19), 
       LOCATE('</subfield>', biblioitems.marcxml, LOCATE('<subfield code="u">', 
       biblioitems.marcxml, LOCATE('<datafield tag="856"', 
       biblioitems.marcxml)+19)) - LOCATE('<subfield code="u">', biblioitems.marcxml, 
       LOCATE('<datafield tag="856"', biblioitems.marcxml)+19)) AS url 
FROM biblioitems, biblio 
WHERE biblioitems.biblionumber = biblio.biblionumber AND url IS NOT NULL

Count of URL's from 856

  • Developer: From listserv provided to David Schuster
  • Module: Catalog
  • Purpose: count of URL's from 856
  • Status: Complete
SELECT count(*) FROM biblioitems WHERE biblioitems url != 'null';

Records without items

  • Developer: Magnus Enger
  • Module: Catalog
  • Purpose: Records without items, with links to OPAC and Intranet
  • Status: Complete
  • Note: Revised by Jared Camins-Esakov to provide correct link to OPAC based on OPACBaseURL
SELECT b.title AS Title, CONCAT('<a href=\"', IF(CHAR_LENGTH(systempreferences.value), CONCAT('http://', systempreferences.value), ''), '/cgi-bin/koha/opac-detail.pl?biblionumber=',b.biblionumber,'\">',b.biblionumber,'</a>') AS OPAC,
  CONCAT('<a href=\"/cgi-bin/koha/catalogue/detail.pl?biblionumber=',b.biblionumber,'\">',b.biblionumber,'</a>') AS Edit  
FROM systempreferences, biblio AS b 
  LEFT JOIN items AS i ON b.biblionumber = i.biblionumber 
WHERE i.itemnumber IS NULL AND systempreferences.variable='OPACBaseURL'

Call Number Shelflist

  • Developer: Jane Wagner, PTFS
  • Module: Catalog
  • Purpose: list in call number order
  • Status: Completed
SELECT items.itemcallnumber,items.datelastborrowed,biblio.title,biblioitems.publicationyear 
FROM items 
LEFT JOIN biblioitems ON (items.biblioitemnumber=biblioitems.biblioitemnumber) 
LEFT JOIN biblio ON (biblioitems.biblionumber=biblio.biblionumber) 
ORDER BY items.cn_sort ASC

Duplicate titles

  • Developer: D Ruth Bavousett, ByWater Solutions
  • Module: Catalog
  • Purpose: Checks for exact duplicates on author/title combo; download for full list (doesn't paginate)
  • Status: Completed
SELECT GROUP_CONCAT(biblionumber SEPARATOR ', ') AS biblionumbers, title, author 
FROM biblio 
GROUP BY CONCAT(title,"/",author) HAVING COUNT(CONCAT(title,"/",author))>1

Duplicate titles (with same date)

  • Developer: Jared Camins-Esakov
  • Module: Catalog
  • Purpose: Based on druthb's report for duplicate titles, but considers date as well; download for full list (doesn't paginate)
  • Status: Completed
SELECT GROUP_CONCAT(biblionumber SEPARATOR ', ') AS biblionumbers, title, author,copyrightdate 
FROM biblio 
GROUP BY CONCAT(title,"/",author,"/",copyrightdate) HAVING COUNT(CONCAT(title,"/",author,"/",copyrightdate))>1

Duplicate ISBNs

  • Developer: Jared Camins-Esakov, ByWater Solutions
  • Module: Catalog
  • Purpose: Show records with duplicate ISBNs; download for full list (doesn't paginate)
  • Status: Completed
SELECT GROUP_CONCAT(biblionumber SEPARATOR ', ') AS biblionumbers, isbn 
FROM biblioitems 
GROUP BY isbn 
HAVING COUNT(isbn)>1

Duplicate Titles (using title and ISBN)

  • Developer: Nicole C. Engard, ByWater Solutions
  • Module: Catalog
  • Purpose: Show records with duplicate titles (using the first 9 characters) and duplicate ISBNs
  • Status: Completed
SELECT GROUP_CONCAT(b.biblionumber SEPARATOR ', ') AS biblionumbers, b.title, 
       b.author, GROUP_CONCAT(i.isbn SEPARATOR ', ') AS isbns 
FROM biblio b 
LEFT JOIN biblioitems i 
ON (i.biblionumber=b.biblionumber)
GROUP BY CONCAT(substr(b.title,0,9),"/",i.isbn) 
HAVING COUNT(CONCAT(substr(b.title,0,9),"/",i.isbn))>1

Duplicate ISBNs with Links to Bib Records

  • Developer: Zachary Spalding, SENYLRC
  • Module: Catalog
  • Purpose: Show records with duplicate ISBNs; download for full list (doesn't paginate) and has links to bib records. Based on ISBN report written by Jared Camins-Esakov
  • Status: Completed
SELECT  GROUP_CONCAT('<a href=\"/cgi-bin/koha/catalogue/detail.pl?biblionumber=',biblionumber,'\">',biblionumber,'</a>') AS biblionumbers, 
        isbn 
FROM biblioitems 
GROUP BY isbn, itemtype 
HAVING COUNT(isbn)>1

Duplicate bibs using the 001

  • Developer: Katrin Fischer and Nicole C. Engard, ByWater Solutions
  • Module: Catalog
  • Purpose: Show records with duplicate 001 fields
  • Status: Completed
SELECT GROUP_CONCAT(biblionumber SEPARATOR ', ') AS biblionumbers, 
       ExtractValue(marcxml,'//controlfield[@tag="001"]') AS id 
FROM biblioitems  
GROUP BY id  
HAVING count(id) > 1

Bibs with specific keyword in subjects

  • Developer: Chris Cormack & Nicole C. Engard, ByWater Solutions
  • Module: Catalog
  • Purpose: This report shows all bib records with a subject that contains a specific keyword in the 650a
  • Status: Completed
SELECT CONCAT('<a href=\"/cgi-bin/koha/catalogue/detail.pl?biblionumber=',biblionumber,'\">',biblionumber,'</a>')
AS bibnumber, lcsh 
FROM 
(SELECT biblionumber, ExtractValue(marcxml,'//datafield[@tag="650"]/subfield[@code>="a"]')
AS lcsh FROM biblioitems) 
AS subjects 
WHERE lcsh 
LIKE "%KEYWORD%"

Bibs without subjects

  • Developer: Nicole C. Engard, ByWater Solutions
  • Module: Catalog
  • Purpose: Shows all bibs without subject headings
  • Status: Complete
SELECT CONCAT('<a href=\"/cgi-bin/koha/catalogue/detail.pl?biblionumber=',biblionumber,'\">',biblionumber,'</a>')
AS bibnumber 
FROM 
(SELECT biblionumber, ExtractValue(marcxml,'//datafield[@tag="650"]/subfield[@code>="a"]') AS sub1, 
ExtractValue(marcxml,'//datafield[@tag="651"]/subfield[@code>="a"]') AS sub2, 
ExtractValue(marcxml,'//datafield[@tag="600"]/subfield[@code>="a"]') AS sub3, 
ExtractValue(marcxml,'//datafield[@tag="610"]/subfield[@code>="a"]') AS sub4, 
ExtractValue(marcxml,'//datafield[@tag="611"]/subfield[@code>="a"]') AS sub5, 
ExtractValue(marcxml,'//datafield[@tag="630"]/subfield[@code>="a"]') AS sub6, 
ExtractValue(marcxml,'//datafield[@tag="648"]/subfield[@code>="a"]') AS sub7, 
ExtractValue(marcxml,'//datafield[@tag="653"]/subfield[@code>="a"]') AS sub8, 
ExtractValue(marcxml,'//datafield[@tag="654"]/subfield[@code>="a"]') AS sub9, 
ExtractValue(marcxml,'//datafield[@tag="655"]/subfield[@code>="a"]') AS sub10, 
ExtractValue(marcxml,'//datafield[@tag="656"]/subfield[@code>="a"]') AS sub11, 
ExtractValue(marcxml,'//datafield[@tag="657"]/subfield[@code>="a"]') AS sub12, 
ExtractValue(marcxml,'//datafield[@tag="658"]/subfield[@code>="a"]') AS sub13, 
ExtractValue(marcxml,'//datafield[@tag="662"]/subfield[@code>="a"]') AS sub14 
FROM biblioitems) AS subjects 
WHERE sub1 = "" 
AND sub2 = "" 
AND sub3 = "" 
AND sub4 = "" 
AND sub5 = "" 
AND sub6 = "" 
AND sub7 = "" 
AND sub8 = "" 
AND sub9 ="" 
AND sub10 = "" 
AND sub11 = "" 
AND sub12 = "" 
AND sub13 = "" 
AND sub14 =""

Bibs without items

  • Developer: Frédéric Demians
  • Module: Catalog
  • Purpose: Get biblionumber of biblio records without items and which itemtype doesn't belongs to a list
  • Status: Complete
SELECT
 biblio.biblionumber
FROM
 biblio
RIGHT JOIN
 biblioitems
ON
 biblio.biblionumber = biblioitems.biblionumber
LEFT JOIN
 items
ON
 biblio.biblionumber = items.biblionumber
WHERE
 items.biblionumber IS NULL
 AND
 itype NOT IN ('AGH', 'PER');

Bibs Suppressed in OPAC

  • Developer: Chris Hobbs, New Haven Unified School District
  • Module: Catalog
  • Purpose: Finds all bibs that have been flagged as Suppressed in 942$n
  • Status: Completed
  SELECT concat( '<a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=', biblio.biblionumber, '">', biblio.title, '</a>' ) AS title, biblio.author
  FROM biblioitems
  JOIN biblio ON ( biblioitems.biblionumber = biblio.biblionumber )
  WHERE ExtractValue( marcxml, '//datafield[@tag="942"]/subfield[@code="n"]' )
  IN ('Y', '1')

List of Items Marked Lost/Missing

  • Developer: Nicole C. Engard, ByWater Solutions
  • Module: Catalog
  • Purpose: Finds all items that are marked as lost in some way.
  • Status: Completed
SELECT items.itemnumber, biblio.title, biblio.author, items.itemcallnumber, 
       items.barcode, authorised_values.lib 
FROM items 
LEFT JOIN biblio ON (items.biblionumber=biblio.biblionumber) 
LEFT JOIN authorised_values ON (items.itemlost=authorised_values.authorised_value) 
WHERE items.itemlost != 0 AND authorised_values.category='LOST'

Validate Codabar barcodes used by North American libraries

  • Developer: Jared Camins-Esakov
  • Module: Catalog
  • Purpose: Identifies barcodes that are invalid based on the rules at http://www.mecsw.com/specs/codabar.html
  • Status: Completed
  • Note: Change '8060' to the 4-digit code used by your library
SELECT biblionumber, barcode, CONCAT_WS('; ', lengthproblem, typeproblem, libraryproblem, checksumproblem) 
FROM (
    SELECT
        items.biblionumber AS biblionumber, items.barcode AS barcode, 
        IF(CHAR_LENGTH(TRIM(items.barcode)) <> 14, 'Barcode wrong length', NULL) AS lengthproblem,
        IF(SUBSTR(TRIM(items.barcode), 1, 1) <> '3', 'Not an item barcode', NULL) AS typeproblem,
        IF(SUBSTR(TRIM(items.barcode), 2, 4) <> '8060', 'Wrong library code', NULL) AS libraryproblem,
        IF(MOD(10 - MOD((IF(SUBSTR(TRIM(items.barcode), 1, 1) * 2 >= 10, (SUBSTR(TRIM(items.barcode), 1, 1) * 2) - 9, SUBSTR(TRIM(items.barcode), 1, 1) * 2)) + 
            (SUBSTR(TRIM(items.barcode), 2, 1)) + 
            (IF(SUBSTR(TRIM(items.barcode), 3, 1) * 2 >= 10, (SUBSTR(TRIM(items.barcode), 3, 1) * 2) - 9, SUBSTR(TRIM(items.barcode), 3, 1) * 2)) + 
            (SUBSTR(TRIM(items.barcode), 4, 1)) + 
            (IF(SUBSTR(TRIM(items.barcode), 5, 1) * 2 >= 10, (SUBSTR(TRIM(items.barcode), 5, 1) * 2) - 9, SUBSTR(TRIM(items.barcode), 5, 1) * 2)) + 
            (SUBSTR(TRIM(items.barcode), 6, 1)) + 
            (IF(SUBSTR(TRIM(items.barcode), 7, 1) * 2 >= 10, (SUBSTR(TRIM(items.barcode), 7, 1) * 2) - 9, SUBSTR(TRIM(items.barcode), 7, 1) * 2)) + 
            (SUBSTR(TRIM(items.barcode), 8, 1)) + 
            (IF(SUBSTR(TRIM(items.barcode), 9, 1) * 2 >= 10, (SUBSTR(TRIM(items.barcode), 9, 1) * 2) - 9, SUBSTR(TRIM(items.barcode), 9, 1) * 2)) + 
            (SUBSTR(TRIM(items.barcode), 10, 1)) + 
            (IF(SUBSTR(TRIM(items.barcode), 11, 1) * 2 >= 10, (SUBSTR(TRIM(items.barcode), 11, 1) * 2) - 9, SUBSTR(TRIM(items.barcode), 11, 1) * 2)) + 
            (SUBSTR(TRIM(items.barcode), 12, 1)) + 
            (IF(SUBSTR(TRIM(items.barcode), 13, 1) * 2 >= 10, (SUBSTR(TRIM(items.barcode), 13, 1) * 2) - 9, SUBSTR(TRIM(items.barcode), 13, 1) * 2)), 10), 10) <> SUBSTR(TRIM(items.barcode), 14, 1), 'Check digit bad', NULL) AS checksumproblem
    FROM items) AS quer 
WHERE lengthproblem IS NOT NULL OR libraryproblem IS NOT NULL OR checksumproblem IS NOT NULL

Find unused sequential barcode ranges

  • Developer: Jared Camins-Esakov
  • Module: Catalog
  • Purpose: Find ranges of unused barcodes.
  • Status: Completed
  • Note: This query takes a *long* time. Minutes, not seconds. This query will only work on non-checksummed, sequential numeric barcodes
SELECT Convert(l.barcode, UNSIGNED) + 1 AS start, MIN(Convert(fr.barcode, UNSIGNED)) - 1 AS stop
FROM items AS l
    LEFT OUTER JOIN items AS r ON Convert(l.barcode, UNSIGNED) = Convert(r.barcode, UNSIGNED) - 1
    LEFT OUTER JOIN items AS fr ON Convert(l.barcode, UNSIGNED) < Convert(fr.barcode, UNSIGNED)
WHERE r.barcode IS NULL AND fr.barcode IS NOT NULL
GROUP BY l.barcode, r.barcode
ORDER BY l.barcode


Title/Subtitle List

  • Developer: Katrin Fischer
  • Module: Catalog
  • Purpose: List of full titles (title and subtitle) with call numbers
  • Status: Completed
SELECT concat(b.title, ' ', ExtractValue((
    SELECT marcxml 
    FROM biblioitems b2
    WHERE b.biblionumber = b2.biblionumber),
      '//datafield[@tag="245"]/subfield[@code="b"]')) AS title, 
    b.author, i.itemcallnumber FROM biblio b LEFT JOIN items i ON (i.biblionumber=b.biblionumber)

Records Cataloged with a Specific Framework

  • Developer: Nicole C. Engard, ByWater Solutions
  • Module: Catalog
  • Purpose: Provides a list of titles cataloged with a specific framework, handy for finding items added using Fast Add.
  • Status: Completed
SELECT title, author 
FROM biblio 
WHERE frameworkcode=<<Enter Framework Code>>

Withdrawn Titles List to Send to OCLC

  • Developer: Nicole C. Engard, ByWater Solutions
  • Module: Catalog
  • Purpose: Provides title, author and OCLC number of withdrawn titles for sending to OCLC to update your holdings in a batch.
  • Status: Completed
SELECT b.title, b.author, ExtractValue((
    SELECT marcxml
    FROM biblioitems b2
    WHERE b.biblionumber = b2.biblionumber),
      '//datafield[@tag="035"]/subfield[@code="a"]') AS 'OCLC Number' 
FROM biblio b 
LEFT JOIN items i 
USING (biblionumber) 
WHERE i.wthdrawn > 0


Collection Evaluation Report

  • Developer: Nicole C. Engard, ByWater Solutions
  • Module: Catalog
  • Purpose: Collection Evaluation report asks for branch, shelving location, data acquired range and date last borrowed range and returns titles
  • Status: Completed
SELECT b.title, b.author, b.copyrightdate, i.itemcallnumber 
FROM biblio b 
LEFT JOIN items i 
USING (biblionumber) 
WHERE i.homebranch=<<Branch|branches>> AND i.location=<<Shelving location|LOC>> 
          AND i.dateaccessioned BETWEEN <<Date acquired BETWEEN (yyyy-mm-dd)>> AND 
         <<and (yyyy-mm-dd)>> AND i.datelastborrowed BETWEEN 
         <<Date last checked out BETWEEN (yyyy-mm-dd)>> AND 
         <<and (yyyy-mm-dd)>>
ORDER BY i.itemcallnumber ASC

Collection Evaluation Report 2

  • Developer: Nicole C. Engard and Ian Walls, ByWater Solutions
  • Module: Catalog
  • Purpose: Shows entire collection with publication info pulled from the 008 (Tip: would be wise to add a filter of some sort to this)
  • Status: Completed
SELECT b.title, b.author, i.dateaccessioned, i.location, i.itemcallnumber,
i.itype, i.datelastborrowed, i.issues, substring(ExtractValue((
    SELECT marcxml
    FROM biblioitems b2
    WHERE b.biblionumber = b2.biblionumber), 
'//controlfield[@tag="008"]'),8,4) AS 'pub date'
FROM biblio b LEFT JOIN items i USING (biblionumber)

Titles by General Materials Designation (MARC 245$h)

  • Developer: Ian Walls, ByWater Solutions
  • Module: Catalog
  • Purpose: Shows each distinct GMD value in the catalog, with a count of titles for that value. Good for profiling materials, and spotting minor spelling errors
  • Status: Completed
SELECT ExtractValue(marcxml, '//datafield[@tag="245"]/subfield[@code="h"]') AS GMD, 
       count(*) AS COUNT
       FROM biblioitems 
       GROUP BY GMD ORDER BY COUNT DESC


Items added by cataloger

  • Developer: Nicole C. Engard, ByWater Solutions
  • Module: Catalog
  • Purpose: Asks for librarian's borrower number and shows them with a count of items they've added. [Requires CataloguingLog to be on]
  • Status: Completed
SELECT count(timestamp) AS 'items added' 
FROM action_logs 
WHERE module='CATALOGUING' AND user=<<Borrower number>> 
      AND info='item' AND action='ADD'

Titles added by cataloger

  • Developer: Nicole C. Engard, ByWater Solutions
  • Module: Catalog
  • Purpose: Asks for librarian's borrower number and shows them with a count of biblios they've added. [Requires CataloguingLog to be on]
  • Status: Completed
SELECT count(timestamp) AS 'titles added' 
FROM action_logs 
WHERE module='CATALOGUING' AND user=<<Borrower number>> 
      AND info!='item' AND action='ADD'

Accounting Reports (Fines/Credits/Etc)

Patrons w/ Fines

  • Developer: Katrin Fischer
  • Module: Accounting
  • Purpose: List patrons with their fine amounts
  • Status: Complete
SELECT 
    (SELECT CONCAT('<a href=\"/cgi-bin/koha/members/boraccount.pl?borrowernumber=',b.borrowernumber,'\">', b.surname,', ', b.firstname,'</a>') 
    FROM borrowers b WHERE b.borrowernumber = a.borrowernumber) AS Patron, 
    format(sum(amountoutstanding),2) AS 'Outstanding',
    (SELECT count(i.itemnumber) FROM issues i WHERE b.borrowernumber = i.borrowernumber) AS 'Checkouts'
FROM 
    accountlines a, borrowers b
WHERE 
    (SELECT sum(amountoutstanding) FROM accountlines a2 WHERE a2.borrowernumber = a.borrowernumber)  > '0.00'
    AND a.borrowernumber = b.borrowernumber
GROUP BY 
    a.borrowernumber ORDER BY b.surname, b.firstname, Outstanding ASC

Patrons w/ credits

  • Developer: Jane Wagner, PTFS
  • Module: Accounting
  • Purpose:
  • Status: Complete
SELECT borrowers.surname, borrowers.firstname, borrowers.cardnumber, address, city, zipcode, round(Sum(accountlines.amountoutstanding),2) AS 'total owed' 
FROM accountlines LEFT JOIN borrowers ON (accountlines.borrowernumber=borrowers.borrowernumber) WHERE amountoutstanding != 0 
GROUP BY accountlines.borrowernumber HAVING sum(accountlines.amountoutstanding) < 0 
ORDER BY borrowers.surname, borrowers.firstname

Collections Report for Unique Management

  • Developer: A team effort: Thatcher Rea - ByWater Solutions, Nicole Engard - ByWater Solutions, Katrin Fischer - BSZ, Liz Rea - NEKLS
  • Module: Accounting
  • Purpose: Outputs patrons with fines in certain categories, with more than $X in fines, and no fine payments in the last 60 days.
  • Status: Completed
SELECT borrowers.cardnumber, borrowers.surname, borrowers.firstname, borrowers.address, borrowers.city, borrowers.zipcode, borrowers.email, borrowers.phone, borrowers.dateofbirth, borrowers.debarred, FORMAT(SUM(accountlines.amountoutstanding),2) AS Due 
FROM borrowers, accountlines 
WHERE borrowers.categorycode IN ('BONN-CITY', 'OTT-CITY') 
AND borrowers.borrowernumber 
IN (SELECT DISTINCT borrowernumber FROM accountlines WHERE accountlines.date < DATE_SUB(CURDATE(),INTERVAL 60 DAY) AND (accountlines.accounttype = 'PAY' OR accountlines.accounttype='C') ) 
AND borrowers.borrowernumber = accountlines.borrowernumber 
GROUP BY borrowers.borrowernumber 
HAVING SUM(accountlines.amountoutstanding) >= 25.00 
ORDER BY borrowers.surname ASC;

Total Forgiven Fines Today

  • Developer: Nicole C. Engard, ByWater Solutions
  • Module: Accounting
  • Purpose: Total amount forgiven in fines today
  • Status: Complete


SELECT SUM(amount) 
  FROM accountlines 
  WHERE DATE(timestamp)=CURDATE() AND (accounttype='FOR' OR accounttype='W')

Total Fines Paid Today

  • Developer: Nicole C. Engard, ByWater Solutions
  • Module: Accounting
  • Purpose: Total amount paid in fines today
  • Status: Complete


SELECT SUM(amount) 
  FROM accountlines 
  WHERE DATE(timestamp)=CURDATE() AND (accounttype='PAY' OR accounttype='C')

Yesterday's Fines by branch

  • Developer: Jane Wagner, PTFS
  • Module: Accounting
  • Purpose: Fines charged yesterday for a particular branch (edit branchcode as needed)
  • Status: Complete


SELECT 
  round(Sum(accountlines.amount),2) AS 'Fines Charged Yesterday'
FROM accountlines 
LEFT JOIN borrowers ON (accountlines.borrowernumber=borrowers.borrowernumber) 
WHERE (accounttype = 'F' OR accounttype = 'FU' ) AND date = (now() - interval 1 day) AND borrowers.branchcode = 'LIB'

Yesterday's Fines

  • Developer: Jane Wagner, PTFS
  • Module: Accounting
  • Purpose: Fines charged yesterday (entire system)
  • Status: Complete


SELECT round(Sum(accountlines.amount),2) AS 'Fines Charged Yesterday'
FROM accountlines WHERE (accounttype = 'F' OR accounttype = 'FU' ) AND date = (now() - interval 1 day)

Yesterday's Lost Item Charges by branch

  • Developer: Jane Wagner, PTFS
  • Module: Accounting
  • Purpose: lost items charged yesterday for a particular branch (edit branchcode as needed)
  • Status: Complete


SELECT 
  round(Sum(accountlines.amount),2) AS 'Lost Items Charged Yesterday'
FROM accountlines 
LEFT JOIN borrowers ON (accountlines.borrowernumber=borrowers.borrowernumber) 
WHERE (accounttype = 'L' ) AND date = (now() - interval 1 day) AND borrowers.branchcode = 'LIB'

Yesterday's Lost Item Charges

  • Developer: Jane Wagner, PTFS
  • Module: Accounting
  • Purpose: lost items charged yesterday (entire system)
  • Status: Complete


SELECT round(Sum(accountlines.amount),2) AS 'Lost Items Charged Yesterday'
FROM accountlines WHERE (accounttype = 'L' ) AND date = (now() - interval 1 day)

Yesterday's Account Management Fees by branch

  • Developer: Jane Wagner, PTFS
  • Module: Accounting
  • Purpose: acct mgt charged yesterday for a particular branch (edit branchcode as needed)
  • Status: Complete


SELECT 
 round(Sum(accountlines.amount),2) AS 'Lost Items Charged Yesterday'
FROM accountlines 
LEFT JOIN borrowers ON (accountlines.borrowernumber=borrowers.borrowernumber) 
WHERE (accounttype = 'L' ) AND date = (now() - interval 1 day) AND borrowers.branchcode = 'LIB'

Yesterday's Account Management Fees

  • Developer: Jane Wagner, PTFS
  • Module: Accounting
  • Purpose: acct mgt fees charged yesterday (entire system)
  • Status: Complete


SELECT round(Sum(accountlines.amount),2) AS 'Lost Items Charged Yesterday'
FROM accountlines WHERE (accounttype = 'L' ) AND date = (now() - interval 1 day)

Yesterday's Forgiven Charges by branch

  • Developer: Jane Wagner, PTFS
  • Module: Accounting
  • Purpose: forgiven charges yesterday for a particular branch (edit branchcode as needed)
  • Status: Complete


SELECT 
  round(Sum(accountlines.amount),2) AS 'Lost Items Charged Yesterday'
FROM accountlines 
LEFT JOIN borrowers ON (accountlines.borrowernumber=borrowers.borrowernumber) 
WHERE (accounttype = 'L' ) AND date = (now() - interval 1 day) AND borrowers.branchcode = 'LIB'

Yesterday's Forgiven Charges (entire system)

  • Developer: Jane Wagner, PTFS
  • Module: Accounting
  • Purpose: forgiven charges yesterday (entire system)
  • Status: Complete


SELECT round(Sum(accountlines.amount),2) AS 'Lost Items Charged Yesterday'
FROM accountlines WHERE (accounttype = 'L' ) AND date = (now() - interval 1 day)

Yesterday's Sundry Fees by branch

  • Developer: Jane Wagner, PTFS
  • Module: Accounting
  • Purpose: sundry fees yesterday for a particular branch (edit branchcode as needed)
  • Status: Complete


SELECT 
  round(Sum(accountlines.amount),2) AS 'Sundry Fees Yesterday'
FROM accountlines LEFT JOIN borrowers ON (accountlines.borrowernumber=borrowers.borrowernumber) 
WHERE (accounttype = 'M') AND date = (now() - interval 1 day) AND borrowers.branchcode = 'LIB'

Yesterday's Sundry Fees (entire system)

  • Developer: Jane Wagner, PTFS
  • Module: Accounting
  • Purpose: sundry fees charged yesterday (entire system)
  • Status: Complete


SELECT round(Sum(accountlines.amount),2) AS 'Sundry Fees Yesterday'
FROM accountlines WHERE (accounttype = 'M') AND date = (now() - interval 1 day)

Yesterday's Credits by branch

  • Developer: Jane Wagner, PTFS
  • Module: Accounting
  • Purpose: credits yesterday for a particular branch (edit branchcode as needed)
  • Status: Complete


SELECT 
  round(Sum(accountlines.amount),2) AS 'Credits Yesterday'
FROM accountlines 
LEFT JOIN borrowers ON (accountlines.borrowernumber=borrowers.borrowernumber) 
WHERE (accounttype = 'C') AND date = (now() - interval 1 day) AND borrowers.branchcode = 'LIB'

Yesterday's Credits (entire system)

  • Developer: Jane Wagner, PTFS
  • Module: Accounting
  • Purpose: credits yesterday (entire system)
  • Status: Complete


SELECT round(Sum(accountlines.amount),2) AS 'Credits Yesterday'
FROM accountlines WHERE (accounttype = 'C') AND date = (now() - interval 1 day)

Yesterday's New Card Fees by branch

  • Developer: Jane Wagner, PTFS
  • Module: Accounting
  • Purpose: new card fees yesterday for a particular branch (edit branchcode as needed)
  • Status: Complete


SELECT 
  round(Sum(accountlines.amount),2) AS 'New Card Fees Yesterday'
FROM accountlines 
LEFT JOIN borrowers ON (accountlines.borrowernumber=borrowers.borrowernumber) 
WHERE (accounttype = 'N') AND date = (now() - interval 1 day) AND borrowers.branchcode = 'LIB'

Yesterday's New Card Fees (entire system)

  • Developer: Jane Wagner, PTFS
  • Module: Accounting
  • Purpose: new card fees yesterday (entire system)
  • Status: Complete


SELECT round(Sum(accountlines.amount),2) AS 'New Card Fees Yesterday'
FROM accountlines WHERE (accounttype = 'N') AND date = (now() - interval 1 day)

Yesterday's Payments by branch

  • Developer: Jane Wagner, PTFS
  • Module: Accounting
  • Purpose: payments yesterday for a particular branch (edit branchcode as needed)
  • Status: Complete


SELECT 
  round(Sum(accountlines.amount),2) AS 'Payments Yesterday'
FROM accountlines 
LEFT JOIN borrowers ON (accountlines.borrowernumber=borrowers.borrowernumber) 
WHERE (accounttype = 'PAY') AND date = (now() - interval 1 day) AND borrowers.branchcode = 'LIB'

Yesterday's Payments (entire system)

  • Developer: Jane Wagner, PTFS
  • Module: Accounting
  • Purpose: payments yesterday (entire system)
  • Status: Complete


SELECT round(Sum(accountlines.amount),2) AS 'Payments Yesterday'
FROM accountlines WHERE (accounttype = 'PAY') AND date = (now() - interval 1 day)

Year to Date Fines by branch

  • Developer: Jane Wagner, PTFS
  • Module: Accounting
  • Purpose: year to date fines charged for a particular branch (edit branchcode as needed)
  • Status: Complete


SELECT 
  round(Sum(accountlines.amount),2) AS 'Fines Charged YTD' 
FROM accountlines 
LEFT JOIN borrowers ON (accountlines.borrowernumber=borrowers.borrowernumber) 
WHERE (accounttype = 'F' OR accounttype = 'FU' ) AND YEAR(date) = YEAR(NOW()) AND borrowers.branchcode = 'LIB'

Year to Date Fines (entire system)

  • Developer: Jane Wagner, PTFS
  • Module: Accounting
  • Purpose: year to date fines charged (entire system)
  • Status: Complete


SELECT round(Sum(accountlines.amount),2) AS 'Fines Charged YTD' 
FROM accountlines 
WHERE (accounttype = 'F' OR accounttype = 'FU' ) AND YEAR(date) = YEAR(NOW())

Total Fines Owed

  • Developer: Jane Wagner, PTFS
  • Module: Accounting
  • Purpose: total amount of fines owed (entire system)
  • Status: Complete


SELECT FORMAT(Sum(accountlines.amountoutstanding),2) FROM accountlines

Writeoff fine (Date Range wise)

  • Developer: Nikunj Tyagi, DPL
  • Module: Accounting
  • Purpose: writeoff Amount (Date range wise) with patron details (entire system)
  • Status: Complete


SELECT borrowers.borrowernumber, borrowers.cardnumber, accountlines.amount, accountlines.date
FROM accountlines, borrowers WHERE borrowers.borrowernumber = accountlines.borrowernumber AND accounttype = 'W' AND date BETWEEN <<Between (YYYY-MM-DD)>> AND <<and (YYYY-MM-DD>>

Payment (fine) detail (Date Range)

  • Developer: Nikunj Tyagi, DPL
  • Module: Accounting
  • Purpose: Payment (Date range wise) with patron details (entire system)
  • Status: Complete


SELECT borrowers.borrowernumber, borrowers.cardnumber, accountlines.amount, accountlines.date
FROM accountlines, borrowers WHERE borrowers.borrowernumber = accountlines.borrowernumber AND accounttype = 'pay' AND date BETWEEN <<Between (YYYY-MM-DD)>> AND <<and (YYYY-MM-DD>>

Yesterday's Amount Collected (entire system)

  • Developer: Jane Wagner, PTFS
  • Module: Accounting
  • Purpose: amount actually collected yesterday (entire system)
  • Status: Complete


SELECT round(Sum(accountlines.amount),2) AS 'Paid Yesterday' 
FROM accountlines
WHERE (accounttype = 'PAY' ) AND date = (now() - interval 1 day)

Amount Collected in specific Date Range (entire system)

  • Developer: Nicole C. Engard, ByWater Solutions
  • Module: Accounting
  • Purpose: Asks you to enter the date range for which you would like to see all of the money collected at all branches.
  • Status: Complete
SELECT FORMAT(abs(sum(amount)),2) AS 'Total Collected' 
FROM accountlines 
WHERE (accounttype='C' OR accounttype='PAY') AND 
      timestamp BETWEEN <<Between (yyyy-mm-dd)>> AND <<and (yyyy-mm-dd)>>


Accounting for date range

  • Developer: Nicole C. Engard, ByWater Solutions
  • Module: Accounting
  • Purpose: List of all accounting details in date range
  • Status: Complete
SELECT 
CASE accounttype 
      WHEN 'A' THEN 'Account management fee'
      WHEN 'C' THEN 'Credit'
      WHEN 'F' THEN 'Overdue Fine'
      WHEN 'FOR' THEN 'Forgiven'
      WHEN 'FU' THEN 'Overdue Fine Still Accruing'
      WHEN 'L' THEN 'Lost Item'
      WHEN 'M' THEN 'Sundry'
      WHEN 'N' THEN 'New Card'
      WHEN 'PAY' THEN 'Payment'
      WHEN 'W' THEN 'Writeoff'
      ELSE accounttype END  
 AS transaction, SUM(amount)
 FROM accountlines
 WHERE DATE(timestamp) BETWEEN <<Collected BETWEEN (yyyy-mm-dd)>> AND <<and (yyyyy-mm-dd)>>
 GROUP BY accounttype

Statistical reports

Shows the total number of items circulated from a branch other than the owning branch

  • Developer: Nicole C. Engard, ByWater Solutions
  • Module: Statistical (Circulation)
  • Purpose: Shows the total number of items circulated from a branch other than the owning branch
  • Status: Complete
  SELECT count(*) AS total 
  FROM statistics 
  LEFT JOIN items ON (statistics.itemnumber = items.itemnumber) 
  WHERE statistics.branch != items.homebranch AND statistics.datetime BETWEEN <<Between (yyyy-mm-dd)>> AND <<and (yyyy-mm-dd)>>

Patrons with most checkouts in date range

  • Developer: Nicole C. Engard, ByWater Solutions
  • Module: Statistical (Circulation)
  • Purpose: This report will show the top 20 patrons who have checked out the most in a specific time period.
  • Status: Complete
SELECT concat(b.surname,', ',b.firstname) AS name, 
       count(s.borrowernumber) AS checkouts 
FROM statistics s 
LEFT JOIN borrowers b 
USING (borrowernumber) 
WHERE s.datetime BETWEEN <<Top checkouts BETWEEN (yyyy-mm-dd)>> AND <<and (yyyy-mm-dd)>> 
GROUP BY s.borrowernumber 
ORDER BY count(s.borrowernumber) DESC 
LIMIT 20

New materials added

  • Developer: Sharon Moreland
  • Module: Statistical (Circulation)
  • Purpose: New materials added
  • Status: Complete
  SELECT count(i.biblionumber) AS added, i.itype, i.homebranch, i.location FROM items i 
  WHERE YEAR(i.dateaccessioned) = <<Year accessioned (yyyy)>> AND MONTH(i.dateaccessioned) = <<Month accessioned (mm)>> 
  GROUP BY i.homebranch,i.itype,i.location 
  ORDER BY i.homebranch,i.itype,i.location ASC

List Active Patrons by Category for a Specific Month

  • Developer: Jesse Weaver
  • Module: Statistical (Circulation, Reports)
  • Purpose: List Active Patrons by Category for a Specific Month
  • Status: Complete
SELECT YEAR(issuedate), MONTH(issuedate), categorycode, COUNT(DISTINCT borrowernumber) 
FROM old_issues
  LEFT JOIN borrowers USING (borrowernumber) 
GROUP BY YEAR(issuedate), MONTH(issuedate), categorycode

Inactive Borrowers

  • Developer: Jonathan Field
  • Module: Statistical (Circulation, Reports)
  • Purpose: List of Borrowers who have not used the library within a given period
  • Status: Complete
SELECT DISTINCT borrowers.surname, borrowers.firstname, borrowers.cardnumber, borrowers.email 
FROM borrowers
WHERE NOT EXISTS (SELECT borrowernumber FROM statistics WHERE borrowers.borrowernumber = borrowernumber AND statistics.datetime >= 'YYYY-MM-DD')

Notices Reports

Overdue Notices Sent

  • Developer: Nicole C. Engard, ByWater Solutions
  • Module: Notices
  • Purpose: Count of overdue notices sent in a specific time frame (by type). Uses the following codes for overdue messages: ODUE, ODUE2, ODUE3. Edit notice names as necessary.
  • Status: Complete
SELECT monthname(message_queue.time_queued) AS month, year(message_queue.time_queued) AS year, 
       message_queue.letter_code AS notice, count(message_queue.borrowernumber) AS count 
FROM message_queue 
WHERE message_queue.time_queued BETWEEN <<Sent BETWEEN (yyyy-mm-dd)>> AND <<and (yyyy-mm-dd)>> 
      AND (message_queue.letter_code = 'ODUE' OR message_queue.letter_code = 'ODUE2' 
      OR message_queue.letter_code = 'ODUE3') AND STATUS = 'sent' 
GROUP BY year(message_queue.time_queued), month(message_queue.time_queued), message_queue.letter_code

Acquisition Reports

Orders in Date Range

  • Developer: Nicole C. Engard, ByWater Solutions
  • Module: Acquisitions
  • Purpose: Show order information for a specific date period.
  • Status: Complete
SELECT v.name AS vendor, b.title AS 'book title', 
       format(o.listprice,2) AS 'list price', 
       format(o.unitprice,2) AS 'actual price',
       ba.basketname, o.notes 
FROM aqorders o 
LEFT JOIN aqbasket ba USING (basketno) 
LEFT JOIN aqbooksellers v ON (v.id = ba.booksellerid) 
LEFT JOIN biblio b USING (biblionumber) 
WHERE o.entrydate BETWEEN <<Ordered BETWEEN (yyyy-mm-dd)>> AND <<and (yyyy-mm-dd)>>

Ledger

  • Developer: Nicole C. Engard, ByWater Solutions
  • Module: Acquisitions
  • Purpose: Show's a ledger of all items ordered
  • Status: Complete
SELECT b.name AS vendor, i.itype, p.budget_branchcode AS branch, k.basketno,  
       o.entrydate AS 'order date', format(o.listprice,2) AS 'list price', 
       format(o.unitprice,2) AS 'unit price', o.quantity, 
       format(o.totalamount,2) AS 'total amount', o.datereceived AS 'date received' 
FROM aqbasket k 
LEFT JOIN aqbooksellers b ON (k.booksellerid=b.id) 
LEFT JOIN aqorders o USING (basketno)
LEFT JOIN items i USING (biblioitemnumber)
LEFT JOIN aqbudgets p USING (budget_id)

Titles ordered in a Fund

  • Developer: Nicole C. Engard, ByWater Solutions
  • Module: Acquisitions
  • Purpose: Titles ordered in a specific fund
  • Status: Complete
SELECT b.title, b.author 
FROM biblio b 
LEFT JOIN aqorders a 
USING (biblionumber) 
LEFT JOIN aqbudgets aq 
USING (budget_id) 
WHERE a.datereceived BETWEEN <<Date received BETWEEN (yyyy-mm-dd)>> 
          AND <<and (yyyy-mm-dd)>> AND
          aq.budget_code LIKE <<Budget code (USING % FOR wildcard)>>

Amount Encumbered

  • Developer: Nicole C. Engard, ByWater Solutions
  • Module: Acquisitions
  • Purpose: Total encumbered against each budget
  • Status: Complete
SELECT b.budget_name, format(sum(b.budget_amount),2) AS 'amount budgeted',
          format(sum(o.listprice*o.quantity),2) AS 'amount encumbered' 
FROM aqorders o 
LEFT JOIN aqbudgets b USING (budget_id)
WHERE o.datereceived IS NULL 
GROUP BY b.budget_name

Amount Spent

  • Developer: Nicole C. Engard, ByWater Solutions
  • Module: Acquisitions
  • Purpose: Total spent against each budget
  • Status: Complete
SELECT b.budget_name, format(sum(b.budget_amount),2) AS 'amount budgeted',
          format(sum(o.listprice*o.quantity),2) AS 'amount spent' 
FROM aqorders o 
LEFT JOIN aqbudgets b USING (budget_id)
WHERE o.datereceived IS NOT NULL 
GROUP BY b.budget_name

Serial reports

Shows the total serial received during the month

  • Developer: Nikunj Tyagi, DPL
  • Module: Serial
  • Purpose: Shows the total serials received with Title, Frequency, latest issue detail
  • Status: Complete
  SELECT serial.subscriptionid,serial.biblionumber,serial.serialid,biblio.title,serial.serialseq,serial.planneddate,serial.publisheddate,
IF( LOCATE('<datafield tag="310"', biblioitems.marcxml) = 0 OR LOCATE('<subfield code="a">', biblioitems.marcxml,
LOCATE('<datafield tag="310"', biblioitems.marcxml)) = 0 OR LOCATE('<subfield code="a">', biblioitems.marcxml,
LOCATE('<datafield tag="310"', biblioitems.marcxml)) > LOCATE('</datafield>', biblioitems.marcxml, LOCATE('<datafield tag="310"', biblioitems.marcxml)), '',
SUBSTRING( biblioitems.marcxml,
LOCATE('<subfield code="a">', biblioitems.marcxml, LOCATE('<datafield tag="310"', biblioitems.marcxml)) + 19,
LOCATE('</subfield>', biblioitems.marcxml, LOCATE('<subfield code="a">', biblioitems.marcxml,
LOCATE('<datafield tag="310"', biblioitems.marcxml)) + 19) -(LOCATE('<subfield code="a">', biblioitems.marcxml,
LOCATE('<datafield tag="310"', biblioitems.marcxml)) + 19)))
AS FREQUENCY  FROM serial, biblio,biblioitems
WHERE serial.biblionumber = biblio.biblionumber AND serial.biblionumber=biblioitems.biblionumber AND  MONTH(planneddate) = 03 AND YEAR(planneddate)= 2011 AND (STATUS)=2
ORDER BY serial.subscriptionid ASC

missing/late/claimed serial during the month

  • Developer: Nikunj Tyagi, DPL
  • Module: Serial
  • Purpose: Shows the total serials missing/late/claimed with Title, Frequency, latest issue detail status 3=late,4=missing,5=claimed
  • Status: Complete
  SELECT serial.subscriptionid,serial.biblionumber,serial.serialid,biblio.title,serial.serialseq,serial.planneddate,serial.publisheddate, 
IF( LOCATE('<datafield tag="310"', biblioitems.marcxml) = 0 OR LOCATE('<subfield code="a">', biblioitems.marcxml, 
LOCATE('<datafield tag="310"', biblioitems.marcxml)) = 0 OR LOCATE('<subfield code="a">', biblioitems.marcxml, 
LOCATE('<datafield tag="310"', biblioitems.marcxml)) > LOCATE('</datafield>', biblioitems.marcxml, LOCATE('<datafield tag="310"', biblioitems.marcxml)), '', 
SUBSTRING( biblioitems.marcxml,
LOCATE('<subfield code="a">', biblioitems.marcxml, LOCATE('<datafield tag="310"', biblioitems.marcxml)) + 19, 
LOCATE('</subfield>', biblioitems.marcxml, LOCATE('<subfield code="a">', biblioitems.marcxml, 
LOCATE('<datafield tag="310"', biblioitems.marcxml)) + 19) -(LOCATE('<subfield code="a">', biblioitems.marcxml, 
LOCATE('<datafield tag="310"', biblioitems.marcxml)) + 19))) 
AS FREQUENCY,serial.STATUS  FROM serial, biblio,biblioitems
WHERE serial.biblionumber = biblio.biblionumber AND serial.biblionumber=biblioitems.biblionumber AND  MONTH(planneddate) = XX AND YEAR(planneddate)= XXXX AND (STATUS) BETWEEN '3' AND '5'
ORDER BY serial.subscriptionid ASC

Late Issues

  • Developer: Nicole C. Engard, ByWater Solutions
  • Module: Serials
  • Purpose: A list of items that should have arrived by now
  • Status: Complete
SELECT b.title, s.serialseq, s.planneddate 
FROM serial s LEFT JOIN biblio b USING (biblionumber) 
WHERE s.planneddate < CURDATE()

Latest Issues

  • Developer: Nicole C. Engard, ByWater Solutions
  • Module: Serials
  • Purpose: A list of the latest issue received for each subscription
  • Status: Complete
SELECT b.title, b.biblionumber, MAX(CONCAT(s.publisheddate, ' / ',s.serialseq)) AS 'date and enumeration' 
FROM serial s 
LEFT JOIN biblio b USING (biblionumber) 
WHERE s.STATUS=2 
GROUP BY b.biblionumber 
ORDER BY s.publisheddate DESC

Misc Reports

List of Lists

  • Developer: Nicole C. Engard, ByWater Solutions
  • Module: Lists
  • Purpose: Show all lists with their creator
  • Status: Complete
SELECT b.borrowernumber, b.surname, b.firstname, 
       s.shelfname 
FROM virtualshelves s 
LEFT JOIN borrowers b 
ON (b.borrowernumber=s.owner)

Backup/Share OPAC Layout from system preferences

  • Developer: Liz Rea, NEKLS
  • Module: Administration
  • Purpose: Dump the contents of all of the OPAC Interface user input customization preferences, for backup or sharing of layout/CSS
  • Status: Complete
SELECT variable, value 
FROM systempreferences 
WHERE variable IN ('OPACUserCSS', 'opacuserjs', 'OPACResultsSidebar', 'OPACNoResultsFound', 'OpacNav', 'opaccredits','opacheader', 'OpacMainUserBlock')

WISHLIST

Requester Module Purpose of request SQL Request Notes
Arron Birch Catalog To create a report that pulls individual fields of a MARC record I am trying to run reports of specific fields of a MARC record. Preferable I would like a general report that lets me change what field I would like to run a report for. For the current assignment I am wanting to run a report with the 300 field of the MARC record.
Nora Blake Holds Statistical Count by month of number of hold requests MADE by each branch all in one report Don't want to have to run this separately for each site
Nora Blake Holds Statistical Count by month of number of hold requests FILLED by each branch all in one report Don't want to have to run this separately for each site
Nora Blake Catalog Statistical Count by month of total number of items held by each branch all in one report A report that generates total counts has been written. Is there a way to separate this out by month?
Rachel Hollis Catalog Mismatches between biblioitem 942 and item 952 We think there is value in a report that identifies (by title, call number and biblio ID) records that have item mismatches, specific to our situation are 942 subfields 2 & c and 952 subfields 2 & y. Our Koha 3.01 biblio item loans are controlled by the 942. Additionally we have libraries that use Dewey, LC and locally developed classification schemes. Administration and System Preferences allow for static and variable data that can get mismatched.
Joe Tholen Circulation List items not circulated in last year, by shelf location, using old_issues and issues For migrated libraries to weed with.
Scotty Zollars Cataloging List all records with NULL in the source of acquistion field in the item record within a date range. ILL
Scotty Zollars Circulation List interlibrary loan materials check out to other libraries, by day. For ILL record keeping
Susan Bennett Catalog I need to eliminate materials that are on the holds shelf waiting for patron pick up from the following SQL. What is the flag in the record?
SELECT items.barcode, items.homebranch, items.itemcallnumber, items.holdingbranch, 
items.location, items.ccode, items.onloan, biblio.author, biblio.title 
FROM items 
LEFT JOIN biblioitems ON (items.biblioitemnumber=biblioitems.biblioitemnumber)
LEFT JOIN biblio ON (biblioitems.biblionumber=biblio.biblionumber) 
WHERE items.holdingbranch="GW" AND items.homebranch<>items.holdingbranch AND items.onloan IS NULL 
ORDER BY items.holdingbranch ASC
Scotty Zollars Circulation We are only one branch. Our interlibrary loan patrons are community patrons. They have the last name of ILL and the first name of the library, for example Erie Public Library. I need a list of interlibrary loan materials check out to other libraries, by month. i have the following donated so far.
SELECT  monthname(datesent) month,COUNT(*) 
FROM branchtransfers WHERE frombranch="MMM" AND YEAR(datesent)=YEAR(NOW())-1 
GROUP BY month 
ORDER BY month(datesent)
Rachel Hollis Circulation Compare number of items owned by library with number circulating Count of items currently checked out I was recently asked for a percentage or number of items that were checked out. We can see what is on the shelf but don't have an idea of the size of the library if nothing were checked out.