[Koha] SQL edit for Non-circulating items report

David Sale dsale at coastlinelibrarynetwork.org
Sat Aug 1 07:12:13 NZST 2020


Our library is engaged in a weeding project that requires a SQL report for Koha to be customized.

The report we are attempting to customize was written by ByWater Solutions, and it generates a list of items "not seen" in X years, by branch and shelf location.

The existing report is written in SQL as follows:

SELECT i.itemcallnumber, b.biblionumber, b.title, b.author, b.copyrightdate,
       i.barcode, i.datelastseen, i.issues AS totalcheckouts,
FROM items i
LEFT JOIN issues
USING (itemnumber)
LEFT JOIN biblio b
USING (biblionumber)
WHERE homebranch = <<Home Library|branches>> AND location = <<Shelving location|LOC>> AND i.withdrawn=0 AND i.itemlost=0 AND i.damaged=0 AND i.itemnumber NOT IN (SELECT issues.itemnumber FROM issues)
      AND  YEAR(NOW())-YEAR(i.datelastseen) > <<Years NOT seen>>
ORDER BY i.itemcallnumber ASC

We would like to modify this report so that in addition to returning the author, title and copyright date, it also returns the ISBN.

However, adding "b.isbn" to the SELECT list (as with "b.title", "b.author", etc.) breaks the report and renders it non-functional.

Can anyone suggest how the SQL given above should be modified to create a functional report that will generate a list of items "not seen" in X years, by branch and shelf location, and that will return the ISBN *in addition to* the title, author, copyright date and barcode for each item listed in the report?

David Sale
Coastline Library Network
Coos/Curry Counties, Oregon

More information about the Koha mailing list