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.
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
MySQL has some XML handling functions: 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;
Returns 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 ITEM;
Returns the 260$b data for biblionumber 14
Developer | |
Module | |
Purpose | |
Status | |
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 !='LIBRARY' AND items.homebranch = 'LIBRARY'
ORDER BY items.homebranch, issues.issuedate, biblio.title
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='LIBRARY' AND items.holdingbranch != items.homebranch
ORDER BY items.homebranch, issues.issuedate, biblio.title
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
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
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
Developer | Nicole Engard |
Module | Circulation |
Purpose | List patrons with their fine amounts |
Status | Complete |
SELECT borrowers.cardnumber, borrowers.surname, borrowers.firstname,
FORMAT(SUM(accountlines.amountoutstanding),2) AS due
FROM borrowers LEFT JOIN accountlines ON (borrowers.borrowernumber=accountlines.borrowernumber)
WHERE accountlines.amountoutstanding > 0
GROUP BY borrowers.cardnumber
ORDER BY borrowers.surname ASC
Developer | Sharon Moreland |
Module | Circulation |
Purpose | New patrons added |
Status | Complete |
SELECT branchcode,categorycode,COUNT(*)
FROM borrowers WHERE MONTH(dateenrolled) = 04 AND YEAR(dateenrolled)= 2009
GROUP BY branchcode,categorycode
ORDER BY branch
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 = 'LIBRARY'
ORDER BY borrowers.surname ASC, issues.date_due ASC
Developer | Sharon Moreland |
Module | Patrons |
Purpose | Missing e-mails |
Status | Complete |
SELECT cardnumber, surname, firstname, branchcode, debarred, dateexpiry
FROM borrowers
WHERE ' ' IN (email)
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
Developer | Nicole Engard |
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
Developer | Bev Church, Joe Tholen |
Module | Circulation |
Purpose | List items not circulated since may2008, 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 = 'iola' AND location = 'io50' 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 = 'iola' AND location = 'io50' AND itemnumber NOT IN
(SELECT itemnumber FROM old_issues WHERE date(issuedate) BETWEEN 2008-05-01 AND curdate()) )
ORDER BY itemcallnumber, barcode
Developer | Nicole Engard, 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
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="Me" AND YEAR(datesent)=YEAR(NOW())-1
GROUP BY month
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
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
Developer | Scotty Zollars |
Module | Circulation |
Purpose | List interlibrary loan materials check out to other libraries, by month |
Status | Change “MMM” to whatever you need 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="MMM" AND YEAR(datesent)=YEAR(NOW())-1
GROUP BY month ORDER BY month(datesent)
Developer | Nicole Engard |
Module | Circulation |
Purpose | Total amount forgiven in fines today |
Status | Complete |
SELECT SUM(amount)
FROM accountlines
WHERE DATE(timestamp)=CURDATE() AND (accounttype='FOR' OR accounttype='W')
Developer | Nicole Engard |
Module | Circulation |
Purpose | Total amount paid in fines today |
Status | Complete |
SELECT SUM(amount)
FROM accountlines
WHERE DATE(timestamp)=CURDATE() AND (accounttype='PAY' OR accounttype='C')
Developer | Jane Wagner, PTFS |
Module | Circ |
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'
Developer | Jane Wagner, PTFS |
Module | Circ |
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)
Developer | Jane Wagner, PTFS |
Module | circ |
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'
Developer | Jane Wagner, PTFS |
Module | circ |
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)
Developer | Jane Wagner, PTFS |
Module | circ |
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'
Developer | Jane Wagner, PTFS |
Module | circ |
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)
Developer | Jane Wagner, PTFS |
Module | circ |
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'
Developer | Jane Wagner, PTFS |
Module | circ |
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)
Developer | Jane Wagner, PTFS |
Module | circ |
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'
Developer | Jane Wagner, PTFS |
Module | circ |
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)
Developer | Jane Wagner, PTFS |
Module | circ |
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'
Developer | Jane Wagner, PTFS |
Module | circ |
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)
Developer | Jane Wagner, PTFS |
Module | circ |
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'
Developer | Jane Wagner, PTFS |
Module | circ |
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)
Developer | Jane Wagner, PTFS |
Module | circ |
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'
Developer | Jane Wagner, PTFS |
Module | circ |
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)
Developer | Jane Wagner, PTFS |
Module | circ |
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'
Developer | Jane Wagner, PTFS |
Module | circ |
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())
Developer | Jane Wagner, PTFS |
Module | Circ |
Purpose | total amount of fines owed (entire system) |
Status | Complete |
SELECT FORMAT(Sum(accountlines.amountoutstanding),2) FROM accountlines
Developer | Jane Wagner, PTFS |
Module | circ |
Purpose | amount actually collected yesterday (entire system) |
Status | Complete |
SELECT round(Sum(accountlines.amount),2) AS 'Paid Yesterday' FROM accountlinesWHERE (accounttype = 'PAY' ) AND date = (now() - interval 1 day)
Jane Wagner, PTFS | Circ | New Patron List (previous month) | 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 | Complete |
Jane Wagner, PTFS | Patron | New Patron Count (previous month) | 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) | Complete |
Jane Wagner, PTFS | Patron | Count of new patrons enrolled in the previous month, by branch and category code. | 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 | Complete |
Jane Wagner, PTFS | Patron | Year to Date–New Patrons by Branch | SELECT branchcode, categorycode, COUNT(branchcode) as NumberEnrolled FROM borrowers WHERE YEAR(borrowers.dateenrolled) = YEAR(NOW()) GROUP BY branchcode, categorycode | Complete |
Jane Wagner, PTFS | Circ | Checkouts by Call Number (previous month) | 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 | Complete |
Jane Wagner, PTFS | Circ | Renewals by Call Number (previous month) | 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 | Complete |
Jane Wagner, PTFS | Circ | Previous Day's Circ Stats | 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 | Complete |
Jane Wagner, PTFS | Circ | Previous Month's Circ Stats | 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 | Complete |
Jane Wagner, PTFS | Circ | Previous Month's Checkouts/Renewals by Collection Code | 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 | Complete |
Jane Wagner, PTFS | Circ | Previous Month Checkouts/Renews by Patron Category | 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 | Complete |
Developer | Module | Purpose of request | SQL Request | Complete/Needs Work |
Sharon Moreland | Catalog | Total collection size | SELECT count(i.biblionumber) AS added, i.itype, i.homebranch, i.location
FROM items i
WHERE i.dateaccessioned < '2009-01-01'
GROUP BY i.homebranch,i.itype,i.location
ORDER BY i.homebranch,i.itype,i.location ASC
| Complete |
Lenora Oftedahl | Catalog | URLs in Catalog | 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='MAIN'
| Needs work as I only want the URLs, not all barcodes |
Sharon Moreland | Catalog | Null Item Type | 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='LIBRARY'
| Complete |
Rachel Hollis | Catalog | Null Barcodes | 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
| Complete |
Sharon Moreland | Catalog | Items with “X” CCode | 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='LIBRARY' AND items.ccode='COLLCODENAME'
ORDER BY items.dateaccessioned DESC
| Complete |
Sharon Moreland | Catalog | Items with “X” & “Y” ITypes | 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='LIBRARY' AND items.itype='ITEMTYPEX' OR items.homebranch='LIBRARY' AND items.itype='ITEMTYPEY'
ORDER BY items.dateaccessioned DESC
| Complete |
Sharon Moreland | Catalog | Call Numbers | 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='LIBRARY' AND items.itemcallnumber LIKE 'FI%'
ORDER BY items.itemcallnumber ASC
| Complete |
Sharon Moreland | Catalog | Complete Shelf list | 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='LIBRARY'
ORDER BY items.itemcallnumber ASC
| Complete |
Sharon Moreland | Catalog | All Barcodes | 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='LIBRARY'
| Complete |
Sharon Moreland | Catalog | List new items | 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 '2009-03-01' AND'2009-04-27' AND items.homebranch='LIBRARY'
ORDER BY items.itemcallnumber ASC
| Complete |
Nora Blake | Catalog | List of Items added to catalog in last 30 days (includes bibliographic info) | 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='LIBRARY' and DATE_SUB(CURDATE(),INTERVAL 30 DAY) <= items.dateaccessioned
ORDER BY biblio.title asc
| Complete |
Michael Hafen | Catalog | Count of all items | SELECT COUNT(barcode) AS Count FROM items WHERE barcode <> '' AND barcode IS NOT NULL
| Complete |
Michael Hafen | Catalog | Count of all items by Item Type | SELECT itype AS 'Item Type',COUNT(barcode) AS Count FROM items WHERE barcode <> ''
AND barcode IS NOT NULL GROUP BY itype
| Complete |
Michael Hafen | Catalog | Count of all titles | SELECT COUNT(biblionumber) AS Count FROM biblio
| Complete |
Nicole Engard | Catalog | Statistical Count of total number of items held by each branch all in one report | SELECT homebranch,count(itemnumber) as items
FROM items
GROUP BY homebranch
ORDER BY homebranch asc
| Complete |
Nicole Engard | Catalog | All bibs without items | SELECT biblio.biblionumber, biblio.title
FROM biblio
LEFT JOIN items on biblio.biblionumber = items.biblionumber
WHERE items.itemnumber is NULL
| Complete |
Kathy Rippel | Catalog | Weeding tool, we call this the SuperWeeder because it includes all sorts of data to help in decision making | 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='ITYPE' AND items.holdingbranch='BRANCHCODE' AND (items.itemcallnumber LIKE '37%' OR
items.itemcallnumber LIKE '38%' OR items.itemcallnumber LIKE '39%')
ORDER BY items.itemcallnumber
| Complete |
Jane Wagner, PTFS | Catalog | Damaged Items with Title | 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 | Complete |
Jane Wagner, PTFS | Catalog | Count by Call Number | SELECT count(items.itemcallnumber) as 'Number of Items', items.itemcallnumber FROM items GROUP BY items.itemcallnumber ORDER BY items.itemcallnumber asc | Complete |
Jane Wagner, PTFS | Catalog | Count by Call Number for items added last month | 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 | Complete |
Jane Wagner, PTFS | Catalog | Previous Month Items Created | 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) | Complete |
Jane Wagner, PTFS | Catalog | Previous Month Items Deleted | SELECT count(deleteditems.itemnumber) as ItemsDeleted FROM deleteditems WHERE deleteditems.timestamp like concat(date_format(LAST_DAY(now() - interval 1 month),'%Y-%m-%')) | Complete |
Jane Wagner, PTFS | Catalog | 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.) | 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 | Complete |
Jane Wagner, PTFS | Catalog | 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.) | 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 | Complete |
Jane Wagner, PTFS | Catalog | Withdrawn Items | 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 | Complete |
LibLime provided to David Schuster | Catalog | List of URL's from 856 | 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 | Complete |
From listserv provided to David Schuster | Catalog | count of URL's from 856 | SELECT count(*) FROM biblioitems where biblioitems url != 'null'; | Complete |
Developer | Jane Wagner, PTFS |
Module | Catalog |
Purpose | list in call number order |
Status | Complete |
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
Developer | J. David Bavousett, PTFS |
Module | Catalog |
Purpose | Checks for exact duplicates on author/title combo; download for full list (doesn't paginate) |
Status | Complete |
SELECT GROUP_CONCAT(biblionumber SEPARATOR ', ') AS biblionumbers, title, author FROM biblio GROUP BY CONCAT(title,"/",author) HAVING COUNT(CONCAT(title,"/",author))>1
Developer | Module | Purpose of request | SQL Request | Complete/Needs Work |
Nicole Engard | Circulation | Shows the total number of items circulated from a branch other than the owning branch | SELECT count(*) as total
FROM statistics
LEFT JOIN items on (statistics.itemnumber = items.itemnumber)
WHERE statistics.branch != items.homebranch AND statistics.datetime BETWEEN 'DATE1' and 'DATE2'
| Complete |
Sharon Moreland | Circulation | New materials added | SELECT count(i.biblionumber) as added, i.itype, i.homebranch, i.location from items i
WHERE YEAR(i.dateaccessioned) = 2009 AND MONTH(i.dateaccessioned) = 04
GROUP BY i.homebranch,i.itype,i.location
ORDER BY i.homebranch,i.itype,i.location ASC
| Complete |
Joe Atzberger | Circulation, Reports | List that totals the circulation of each Dewey section, F, and periodicals, by month | 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) = XXXX and MONTH(datetime) = X
GROUP BY DATE(datetime), substring(itemcallnumber,1,1)
| Complete |
Joe Atzberger, Scotty Zollars | Circulation, Reports | List that totals the circulation of each Dewey section, F, and periodicals, by day | 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) = XXXX and MONTH(datetime) = X and DAY(datetime) = X
GROUP BY DATE(datetime), substring(itemcallnumber,1,1)
| Complete |
Jesse Weaver | Circulation, Reports | List Active Patrons by Category for a Specific Month | SELECT YEAR(issuedate), MONTH(issuedate), categorycode, COUNT(DISTINCT borrowernumber) FROM old_issues LEFT JOIN borrowers USING (borrowernumber) GROUP BY YEAR(issuedate), MONTH(issuedate), categorycode
| Complete |
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) |