Skillnad mellan versioner av "Stockholms universitetsbibliotek"
Gunillar (diskussion | bidrag) |
Gunillar (diskussion | bidrag) |
||
Rad 28: | Rad 28: | ||
</pre> | </pre> | ||
+ | '''De 50 mest lånade böckerna ur magasin som bör tas till öppen samling.''' | ||
+ | <pre> | ||
+ | SELECT count(statistics.datetime) AS circs, biblio.title, biblio.author, items.barcode, items.itemcallnumber,items.datelastseen | ||
+ | FROM statistics,biblio,items | ||
+ | WHERE items.itemnumber=statistics.itemnumber | ||
+ | AND biblio.biblionumber=items.biblionumber | ||
+ | AND DATE(statistics.datetime) > DATE_SUB(CURRENT_DATE(),INTERVAL 6 MONTH) | ||
+ | AND DATE(statistics.datetime)<=CURRENT_DATE() | ||
+ | AND statistics.itemnumber IS NOT NULL | ||
+ | AND statistics.type = 'issue' | ||
+ | AND items.itype = <<Skriv item type|itemtypes>> | ||
+ | GROUP BY biblio.biblionumber | ||
+ | ORDER BY circs DESC | ||
+ | LIMIT 50 | ||
+ | </pre> | ||
+ | '''Låntagare med kö-böcker''' | ||
+ | <pre> | ||
+ | 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, issues, items, biblio, reserves | ||
+ | WHERE borrowers.borrowernumber=issues.borrowernumber | ||
+ | AND issues.itemnumber=items.itemnumber | ||
+ | AND items.biblionumber=biblio.biblionumber | ||
+ | AND reserves.borrowernumber = borrowers.borrowernumber | ||
+ | AND reserves.reservedate IS NOT NULL | ||
+ | AND date (reserves.reservedate) < DATE_SUB(CURRENT_DATE(),INTERVAL 1 DAY) | ||
+ | AND reserves.waitingdate IS NULL | ||
+ | AND (TO_DAYS(curdate())-TO_DAYS(date_due)) > '0' | ||
+ | AND (TO_DAYS(curdate())-TO_DAYS(date_due)) < '7' | ||
+ | ORDER BY issues.date_due ASC | ||
+ | </pre> | ||
+ | '''Förkomna fjärrlån utlånade till andra bibliotek''' | ||
+ | <pre> | ||
+ | SELECT b.title, b.author, | ||
+ | i.itemcallnumber,i.barcode, | ||
+ | v.lib AS 'lost', | ||
+ | bo.firstname, | ||
+ | bo.surname | ||
+ | FROM items i | ||
+ | JOIN biblio b ON (i.biblionumber=b.biblionumber) | ||
+ | JOIN authorised_values v ON (i.itemlost=v.authorised_value) | ||
+ | JOIN issues c ON (i.itemnumber=c.itemnumber) | ||
+ | JOIN borrowers bo ON (bo.borrowernumber=c.borrowernumber) | ||
+ | WHERE v.lib='LONG OVERDUE (LOST)' | ||
+ | AND bo.categorycode = <<Fjärrlåns låntagarkategori|categorycode>> | ||
+ | ORDER BY v.lib | ||
+ | </pre> | ||
+ | |||
+ | '''Låntagare som saknar epostadress''' | ||
+ | <pre> | ||
+ | SELECT cardnumber, surname, firstname, dateexpiry | ||
+ | FROM borrowers | ||
+ | WHERE ' ' IN (email) | ||
+ | </pre> | ||
+ | |||
+ | '''Utlån, Omlån, Återlämning''' - ''välj år och månad per enhet | ||
+ | Välj enhet samt år (t ex 2018) och Månad (t ex 05 för maj)'' | ||
+ | <pre> | ||
+ | SELECT | ||
+ | MONTH(datetime) AS Månad, | ||
+ | SUM( IF(type = 'issue', 1, 0 )) AS Utlån, | ||
+ | SUM( IF(type = 'renew', 1, 0 )) AS Omlån, | ||
+ | SUM( IF(type = 'return', 1, 0 )) AS Återlämning, | ||
+ | COUNT(statistics.type) AS 'Total Transactions' | ||
+ | FROM statistics | ||
+ | WHERE branch = <<Enhet|branches>> | ||
+ | AND YEAR(datetime) = <<Välj ÅR ÅÅÅÅ>> | ||
+ | AND MONTH(datetime) = <<Välj månad, tex 05 för maj>> | ||
+ | GROUP BY MONTH(datetime) | ||
+ | </pre> | ||
+ | |||
+ | '''Läsesalslån av böcker med streckkod'''. ''OBS!! Att tidskrifter endast syns via Viola och då endast om de hämtas från magasin''. | ||
+ | <pre> | ||
+ | SELECT branch, | ||
+ | MONTH(datetime) AS Månad, | ||
+ | SUM( IF(type = 'localuse', 1, 0 )) AS Läsesalslån | ||
+ | FROM statistics | ||
+ | WHERE branch =<<Enhet|branches>> | ||
+ | AND YEAR(datetime) = <<Välj ÅR ÅÅÅÅ>> | ||
+ | AND MONTH(datetime) = <<Välj månad, tex 05 för maj>> | ||
+ | </pre> | ||
+ | |||
+ | '''Material utlånat mellan vissa datum. Välj datum, enhet, location och call number''' | ||
+ | <pre> | ||
+ | SELECT | ||
+ | i.itemcallnumber AS 'Call number', | ||
+ | b.author, | ||
+ | b.title, | ||
+ | i.barcode, | ||
+ | ExtractValue( bm.metadata, '//datafield[@tag=035]/subfield[@code="a" and contains(text(), "LIBRIS")]') AS 'LibrisID', | ||
+ | b.biblionumber, | ||
+ | i.itemnumber, | ||
+ | b.copyrightdate, | ||
+ | i.itype AS 'Item type', | ||
+ | i.issues AS 'Antal utlån', | ||
+ | i.onloan AS 'Utlånad', | ||
+ | i.itemlost AS 'Saknad', | ||
+ | i.datelastborrowed AS 'Senast utlånad', | ||
+ | i.datelastseen AS 'Senast sedd', | ||
+ | i.homebranch, | ||
+ | i.location | ||
+ | FROM items i | ||
+ | LEFT JOIN biblio_metadata bm ON (i.biblionumber=bm.biblionumber) | ||
+ | LEFT JOIN biblio b ON (bm.biblionumber=b.biblionumber) | ||
+ | WHERE i.datelastborrowed BETWEEN <<Utlån sedan|date>> AND <<Utlån till|date>> | ||
+ | AND i.homebranch = <<Välj enhet|branches>> | ||
+ | AND i.location = <<Välj location|LOC>> | ||
+ | AND i.itemcallnumber LIKE <<Skriv callnumber ex A%>> | ||
+ | ORDER BY itemcallnumber | ||
+ | </pre> | ||
+ | |||
+ | '''Låntagare med mer än 24 omlån som alltså snart kommer att få sista krav och måste återlämna''' | ||
+ | <pre> | ||
+ | SELECT b.cardnumber, it.barcode, i.renewals, i.date_due, it.homebranch | ||
+ | FROM issues i | ||
+ | LEFT JOIN borrowers b ON (i.borrowernumber=b.borrowernumber) | ||
+ | LEFT JOIN items it ON (i.itemnumber=it.itemnumber) | ||
+ | WHERE i.renewals > '24' | ||
+ | GROUP BY b.borrowernumber, it.barcode, i.date_due, it.homebranch | ||
+ | </pre> | ||
+ | |||
+ | '''Böcker som lånats om mer än 24 ggr och alltså snart bör återlämnas''' | ||
+ | <pre> | ||
+ | SELECT COUNT(*) | ||
+ | FROM issues i | ||
+ | WHERE i.renewals > '24' | ||
+ | </pre> | ||
+ | |||
+ | '''Återlämnad per timme, dag, månad, år'''. ''Välj ett exakt datum för start och ett exakt för slut''. | ||
+ | <pre> | ||
+ | SELECT YEAR(datetime) AS Year, | ||
+ | MONTH(datetime) AS Month, | ||
+ | DAY(datetime) AS Day, | ||
+ | HOUR(datetime) AS Hour, | ||
+ | count(*) | ||
+ | FROM statistics | ||
+ | WHERE datetime BETWEEN <<Mellan|date>> AND <<Och|date>> | ||
+ | AND type = 'return' | ||
+ | GROUP BY Year, Month, Day, Hour | ||
+ | </pre> | ||
+ | |||
+ | '''Antal Utlån per år av böcker på svenska'''. ''Väldigt tung och långsam fråga!'' | ||
+ | <pre> | ||
+ | SELECT substring( ExtractValue(metadata,'//controlfield[@tag="008"]'), 36, 3) AS Språk, COUNT(*) AS Antal | ||
+ | FROM statistics s | ||
+ | LEFT JOIN items i ON (s.itemnumber=i.itemnumber) | ||
+ | LEFT JOIN biblio b ON (i.biblionumber=b.biblionumber) | ||
+ | LEFT JOIN biblio_metadata bm ON (b.biblionumber=bm.biblionumber) | ||
+ | WHERE s.`type`='issue' | ||
+ | AND YEAR(datetime) = <<Välj ÅR ÅÅÅÅ>> | ||
+ | GROUP BY Språk | ||
+ | HAVING Språk = 'swe' | ||
+ | </pre> | ||
+ | |||
+ | '''Antal utlån av böcker på nationellt minoritetsspråk'''.''Väldigt tung och långsam fråga!'' | ||
+ | <pre> | ||
+ | SELECT substring( ExtractValue(metadata,'//controlfield[@tag="008"]'), 36, 3) AS Språk, COUNT(*) AS Antal | ||
+ | FROM statistics s | ||
+ | LEFT JOIN items i ON (s.itemnumber=i.itemnumber) | ||
+ | LEFT JOIN biblio b ON (i.biblionumber=b.biblionumber) | ||
+ | LEFT JOIN biblio_metadata bm ON (b.biblionumber=bm.biblionumber) | ||
+ | WHERE s.`type`='issue' | ||
+ | AND YEAR(datetime) = <<Välj ÅR ÅÅÅÅ>> | ||
+ | GROUP BY Språk | ||
+ | HAVING ( Språk = 'fin' OR Språk = 'smi' OR Språk = '9mk' OR Språk = 'rom' OR Språk = 'yid' ) | ||
+ | </pre> | ||
+ | |||
+ | '''Antal utlån av böcker på utländska språk'''. ''Väldigt tung och långsam fråga!'' | ||
+ | <pre> | ||
+ | SELECT SUBSTRING(ExtractValue(metadata, '//controlfield[@tag="008"]'), 36, 3) != 'swe' | ||
+ | AND SUBSTRING(ExtractValue(metadata, '//controlfield[@tag="008"]'), 36, 3) != 'fin' | ||
+ | AND SUBSTRING(ExtractValue(metadata, '//controlfield[@tag="008"]'), 36, 3) != 'smi' | ||
+ | AND SUBSTRING(ExtractValue(metadata, '//controlfield[@tag="008"]'), 36, 3) != '9mk' | ||
+ | AND SUBSTRING(ExtractValue(metadata, '//controlfield[@tag="008"]'), 36, 3) != 'rom' | ||
+ | AND SUBSTRING(ExtractValue(metadata, '//controlfield[@tag="008"]'), 36, 3) != 'yid', | ||
+ | COUNT(*) AS Antal | ||
+ | FROM statistics s | ||
+ | LEFT JOIN items i ON (s.itemnumber=i.itemnumber) | ||
+ | LEFT JOIN biblio b ON (i.biblionumber=b.biblionumber) | ||
+ | LEFT JOIN biblio_metadata bm ON (b.biblionumber=bm.biblionumber) | ||
+ | WHERE s.`type`='issue' | ||
+ | AND YEAR(datetime) = <<Välj ÅR ÅÅÅÅ>> | ||
+ | </pre> | ||
+ | |||
+ | '''Antal Items per Enhet''' | ||
+ | <pre> | ||
+ | SELECT COUNT(*) | ||
+ | FROM items i | ||
+ | LEFT JOIN biblio_metadata bm ON (i.biblionumber=bm.biblionumber) | ||
+ | WHERE NOT(SUBSTRING(ExtractValue(bm.metadata, '//leader'),8,1) = 's' | ||
+ | AND SUBSTRING(ExtractValue(bm.metadata, '//controlfield[@tag="008"]'),22,1) = 'p') | ||
+ | AND i.homebranch = <<Välj enhet|branches>> | ||
+ | </pre> | ||
== Samlingar == | == Samlingar == |
Versionen från 28 mars 2019 kl. 15.30
Circulation
Antal lån via utlåningsmaskin
SELECT COUNT(s.itemnumber) AS antal FROM statistics s LEFT JOIN action_logs a ON (s.itemnumber=a.object AND s.datetime=a.timestamp) WHERE s.branch = <<Välj enhet|branches>> AND s.`type` = 'issue' AND a.user = <<Skriv borrower id för utlåningsmaskin>> AND date(datetime) BETWEEN <<Startdatum|date>> AND <<Slutdatum|date>>
In Transit Material som ej kommit fram till sin enhet med tillägg homebranch och itemcallnumber
SELECT frombranch, barcode, title, author, homebranch, holdingbranch, itemcallnumber, monthname(datesent) month,COUNT(*) FROM branchtransfers bt, items i, biblio b WHERE bt.itemnumber = i.itemnumber AND i.biblionumber = b.biblionumber AND datesent >= concat(date_format(LAST_DAY(now() - interval 7 month),'%m-'),'01') AND datesent <= LAST_DAY(now() - interval 2 month) AND datearrived IS NULL GROUP BY month, barcode, title, author, homebranch, itemcallnumber
De 50 mest lånade böckerna ur magasin som bör tas till öppen samling.
SELECT count(statistics.datetime) AS circs, biblio.title, biblio.author, items.barcode, items.itemcallnumber,items.datelastseen FROM statistics,biblio,items WHERE items.itemnumber=statistics.itemnumber AND biblio.biblionumber=items.biblionumber AND DATE(statistics.datetime) > DATE_SUB(CURRENT_DATE(),INTERVAL 6 MONTH) AND DATE(statistics.datetime)<=CURRENT_DATE() AND statistics.itemnumber IS NOT NULL AND statistics.type = 'issue' AND items.itype = <<Skriv item type|itemtypes>> GROUP BY biblio.biblionumber ORDER BY circs DESC LIMIT 50
Låntagare med kö-böcker
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, issues, items, biblio, reserves WHERE borrowers.borrowernumber=issues.borrowernumber AND issues.itemnumber=items.itemnumber AND items.biblionumber=biblio.biblionumber AND reserves.borrowernumber = borrowers.borrowernumber AND reserves.reservedate IS NOT NULL AND date (reserves.reservedate) < DATE_SUB(CURRENT_DATE(),INTERVAL 1 DAY) AND reserves.waitingdate IS NULL AND (TO_DAYS(curdate())-TO_DAYS(date_due)) > '0' AND (TO_DAYS(curdate())-TO_DAYS(date_due)) < '7' ORDER BY issues.date_due ASC
Förkomna fjärrlån utlånade till andra bibliotek
SELECT b.title, b.author, i.itemcallnumber,i.barcode, v.lib AS 'lost', bo.firstname, bo.surname FROM items i JOIN biblio b ON (i.biblionumber=b.biblionumber) JOIN authorised_values v ON (i.itemlost=v.authorised_value) JOIN issues c ON (i.itemnumber=c.itemnumber) JOIN borrowers bo ON (bo.borrowernumber=c.borrowernumber) WHERE v.lib='LONG OVERDUE (LOST)' AND bo.categorycode = <<Fjärrlåns låntagarkategori|categorycode>> ORDER BY v.lib
Låntagare som saknar epostadress
SELECT cardnumber, surname, firstname, dateexpiry FROM borrowers WHERE ' ' IN (email)
Utlån, Omlån, Återlämning - välj år och månad per enhet Välj enhet samt år (t ex 2018) och Månad (t ex 05 för maj)
SELECT MONTH(datetime) AS Månad, SUM( IF(type = 'issue', 1, 0 )) AS Utlån, SUM( IF(type = 'renew', 1, 0 )) AS Omlån, SUM( IF(type = 'return', 1, 0 )) AS Återlämning, COUNT(statistics.type) AS 'Total Transactions' FROM statistics WHERE branch = <<Enhet|branches>> AND YEAR(datetime) = <<Välj ÅR ÅÅÅÅ>> AND MONTH(datetime) = <<Välj månad, tex 05 för maj>> GROUP BY MONTH(datetime)
Läsesalslån av böcker med streckkod. OBS!! Att tidskrifter endast syns via Viola och då endast om de hämtas från magasin.
SELECT branch, MONTH(datetime) AS Månad, SUM( IF(type = 'localuse', 1, 0 )) AS Läsesalslån FROM statistics WHERE branch =<<Enhet|branches>> AND YEAR(datetime) = <<Välj ÅR ÅÅÅÅ>> AND MONTH(datetime) = <<Välj månad, tex 05 för maj>>
Material utlånat mellan vissa datum. Välj datum, enhet, location och call number
SELECT i.itemcallnumber AS 'Call number', b.author, b.title, i.barcode, ExtractValue( bm.metadata, '//datafield[@tag=035]/subfield[@code="a" and contains(text(), "LIBRIS")]') AS 'LibrisID', b.biblionumber, i.itemnumber, b.copyrightdate, i.itype AS 'Item type', i.issues AS 'Antal utlån', i.onloan AS 'Utlånad', i.itemlost AS 'Saknad', i.datelastborrowed AS 'Senast utlånad', i.datelastseen AS 'Senast sedd', i.homebranch, i.location FROM items i LEFT JOIN biblio_metadata bm ON (i.biblionumber=bm.biblionumber) LEFT JOIN biblio b ON (bm.biblionumber=b.biblionumber) WHERE i.datelastborrowed BETWEEN <<Utlån sedan|date>> AND <<Utlån till|date>> AND i.homebranch = <<Välj enhet|branches>> AND i.location = <<Välj location|LOC>> AND i.itemcallnumber LIKE <<Skriv callnumber ex A%>> ORDER BY itemcallnumber
Låntagare med mer än 24 omlån som alltså snart kommer att få sista krav och måste återlämna
SELECT b.cardnumber, it.barcode, i.renewals, i.date_due, it.homebranch FROM issues i LEFT JOIN borrowers b ON (i.borrowernumber=b.borrowernumber) LEFT JOIN items it ON (i.itemnumber=it.itemnumber) WHERE i.renewals > '24' GROUP BY b.borrowernumber, it.barcode, i.date_due, it.homebranch
Böcker som lånats om mer än 24 ggr och alltså snart bör återlämnas
SELECT COUNT(*) FROM issues i WHERE i.renewals > '24'
Återlämnad per timme, dag, månad, år. Välj ett exakt datum för start och ett exakt för slut.
SELECT YEAR(datetime) AS Year, MONTH(datetime) AS Month, DAY(datetime) AS Day, HOUR(datetime) AS Hour, count(*) FROM statistics WHERE datetime BETWEEN <<Mellan|date>> AND <<Och|date>> AND type = 'return' GROUP BY Year, Month, Day, Hour
Antal Utlån per år av böcker på svenska. Väldigt tung och långsam fråga!
SELECT substring( ExtractValue(metadata,'//controlfield[@tag="008"]'), 36, 3) AS Språk, COUNT(*) AS Antal FROM statistics s LEFT JOIN items i ON (s.itemnumber=i.itemnumber) LEFT JOIN biblio b ON (i.biblionumber=b.biblionumber) LEFT JOIN biblio_metadata bm ON (b.biblionumber=bm.biblionumber) WHERE s.`type`='issue' AND YEAR(datetime) = <<Välj ÅR ÅÅÅÅ>> GROUP BY Språk HAVING Språk = 'swe'
Antal utlån av böcker på nationellt minoritetsspråk.Väldigt tung och långsam fråga!
SELECT substring( ExtractValue(metadata,'//controlfield[@tag="008"]'), 36, 3) AS Språk, COUNT(*) AS Antal FROM statistics s LEFT JOIN items i ON (s.itemnumber=i.itemnumber) LEFT JOIN biblio b ON (i.biblionumber=b.biblionumber) LEFT JOIN biblio_metadata bm ON (b.biblionumber=bm.biblionumber) WHERE s.`type`='issue' AND YEAR(datetime) = <<Välj ÅR ÅÅÅÅ>> GROUP BY Språk HAVING ( Språk = 'fin' OR Språk = 'smi' OR Språk = '9mk' OR Språk = 'rom' OR Språk = 'yid' )
Antal utlån av böcker på utländska språk. Väldigt tung och långsam fråga!
SELECT SUBSTRING(ExtractValue(metadata, '//controlfield[@tag="008"]'), 36, 3) != 'swe' AND SUBSTRING(ExtractValue(metadata, '//controlfield[@tag="008"]'), 36, 3) != 'fin' AND SUBSTRING(ExtractValue(metadata, '//controlfield[@tag="008"]'), 36, 3) != 'smi' AND SUBSTRING(ExtractValue(metadata, '//controlfield[@tag="008"]'), 36, 3) != '9mk' AND SUBSTRING(ExtractValue(metadata, '//controlfield[@tag="008"]'), 36, 3) != 'rom' AND SUBSTRING(ExtractValue(metadata, '//controlfield[@tag="008"]'), 36, 3) != 'yid', COUNT(*) AS Antal FROM statistics s LEFT JOIN items i ON (s.itemnumber=i.itemnumber) LEFT JOIN biblio b ON (i.biblionumber=b.biblionumber) LEFT JOIN biblio_metadata bm ON (b.biblionumber=bm.biblionumber) WHERE s.`type`='issue' AND YEAR(datetime) = <<Välj ÅR ÅÅÅÅ>>
Antal Items per Enhet
SELECT COUNT(*) FROM items i LEFT JOIN biblio_metadata bm ON (i.biblionumber=bm.biblionumber) WHERE NOT(SUBSTRING(ExtractValue(bm.metadata, '//leader'),8,1) = 's' AND SUBSTRING(ExtractValue(bm.metadata, '//controlfield[@tag="008"]'),22,1) = 'p') AND i.homebranch = <<Välj enhet|branches>>
Samlingar
Bestånd utifrån DDK-klassifikation i den bibliografiska posten (fält 082) på vald enhet (homebranch), location
SELECT i.itemcallnumber, b.author, b.title, i.barcode, ExtractValue (bm.metadata,'//datafield[@tag="035"]/subfield[@code="a" and contains(text(), "LIBRIS")]') AS 'LibrisID', ExtractValue(bm.metadata, '//datafield[@tag="082"]/subfield[@code="a"]') AS 'Dewey', ExtractValue(bm.metadata, '//datafield[@tag="084"]/subfield[@code="a"]') AS 'SAB', b.copyrightdate, i.itype AS 'Item type', i.onloan AS 'Utlånad', i.itemlost, i.homebranch, i.location, b.biblionumber, i.itemnumber FROM items i LEFT JOIN biblio_metadata bm ON (i.biblionumber=bm.biblionumber) LEFT JOIN biblio b ON (bm.biblionumber=b.biblionumber) WHERE i.homebranch = <<Välj enhet|branches>> AND i.location = <<Välj location|LOC>> AND ExtractValue(bm.metadata, '//datafield[@tag="082"]/subfield[@code="a"]') LIKE <<Skriv början på Deweykod ex 839%>> ORDER BY i.itemcallnumber