0% found this document useful (0 votes)
71 views2 pages

Koha Code

The document contains 3 SQL queries: 1) The first query selects data on all completed transactions (issued and returned items) from various tables and orders by return date. 2) The second query selects the same data but limits to items returned between given dates. 3) The third query counts transactions between dates by type (check out, check in, renewal, amnesty, payment, other). It groups the results by transaction type and count.

Uploaded by

Sudhakar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
71 views2 pages

Koha Code

The document contains 3 SQL queries: 1) The first query selects data on all completed transactions (issued and returned items) from various tables and orders by return date. 2) The second query selects the same data but limits to items returned between given dates. 3) The third query counts transactions between dates by type (check out, check in, renewal, amnesty, payment, other). It groups the results by transaction type and count.

Uploaded by

Sudhakar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

All Completed Transactions (Issued and Returned)

SELECT items.holdingbranch, old_issues.issuedate, old_issues.date_due, old_issues.returndate,


items.barcode, biblio.title, biblio.author, borrowers.surname, borrowers.firstname,
borrowers.cardnumber, borrowers.categorycode, items.datelastborrowed, items.datelastseen,
items.location, items.itype, biblioitems.totalissues

FROM old_issues

LEFT JOIN borrowers ON ( borrowers.borrowernumber = old_issues.borrowernumber )

LEFT JOIN items ON ( items.itemnumber = old_issues.itemnumber )

LEFT JOIN biblioitems ON ( items.biblioitemnumber = biblioitems.biblioitemnumber)

LEFT JOIN biblio ON items.biblionumber=biblio.biblionumber

ORDER BY old_issues.returndate DESC

Checked in Between Dates (Return)


SELECT items.holdingbranch, old_issues.issuedate, old_issues.date_due, old_issues.returndate,
items.barcode, biblio.title, biblio.author, borrowers.surname, borrowers.firstname,
borrowers.cardnumber, borrowers.categorycode, items.datelastborrowed, items.datelastseen,
items.location, items.itype, biblioitems.totalissues

FROM old_issues

LEFT JOIN borrowers ON ( borrowers.borrowernumber = old_issues.borrowernumber )

LEFT JOIN items ON ( items.itemnumber = old_issues.itemnumber )

LEFT JOIN biblioitems ON ( items.biblioitemnumber = biblioitems.biblioitemnumber)

LEFT JOIN biblio ON items.biblionumber=biblio.biblionumber

ORDER BY old_issues.returndate DESC

All Transactions Between Dates - Counts

SELECT

CASE type

WHEN 'issue' THEN "Check Outs"

WHEN 'return' THEN "Check Ins"

WHEN 'renew' THEN "Renewals"

WHEN 'writeoff' THEN "Amnesties"

WHEN 'payment' THEN "Payments"


ELSE "Others" END

AS "Transaction types", COUNT(datetime) AS "Quantity"

FROM statistics

WHERE DATE(datetime) BETWEEN '2022-06-01' AND '2023-01-21'

GROUP BY type

You might also like