Skillnad mellan versioner av "Stockholms universitetsbibliotek"

Från Svenska kohanätverkets wiki
Hoppa till navigering Hoppa till sök
Rad 44: Rad 44:
 
'''Låntagare med kö-böcker'''
 
'''Låntagare med kö-böcker'''
 
<pre>
 
<pre>
SELECT borrowers.surname, borrowers.firstname, borrowers.phone, borrowers.cardnumber,  
+
SELECT bo.surname,  
       issues.date_due, biblio.title, biblio.author, items.itemcallnumber, items.barcode,  
+
      bo.firstname,  
       items.homebranch, (TO_DAYS(curdate())-TO_DAYS( date_due)) AS 'days overdue'  
+
      bo.phone,  
FROM borrowers, issues, items, biblio, reserves
+
      bo.cardnumber,  
WHERE borrowers.borrowernumber=issues.borrowernumber  
+
       iu.date_due,  
AND issues.itemnumber=items.itemnumber
+
      bi.title,  
AND items.biblionumber=biblio.biblionumber  
+
      bi.author,  
AND reserves.borrowernumber = borrowers.borrowernumber
+
      it.itemcallnumber,  
AND reserves.reservedate IS NOT NULL
+
      it.barcode,  
AND date (reserves.reservedate) < DATE_SUB(CURRENT_DATE(),INTERVAL 1 DAY)
+
       it.homebranch, (TO_DAYS(curdate())-TO_DAYS( date_due)) AS 'days overdue'  
AND reserves.waitingdate IS NULL
+
FROM reserves r
 +
LEFT JOIN borrowers bo ON (bo.borrowernumber = r.borrowernumber)
 +
LEFT JOIN issues iu ON (iu.borrowernumber=bo.borrowernumber)
 +
LEFT JOIN items it ON (it.itemnumber=iu.itemnumber)
 +
LEFT JOIN biblio bi ON (bi.biblionumber =it.biblionumber)  
 +
WHERE r.reservedate IS NOT NULL
 +
AND date (r.reservedate) < DATE_SUB(CURRENT_DATE(),INTERVAL 1 DAY)
 +
AND r.waitingdate IS NULL
 
AND (TO_DAYS(curdate())-TO_DAYS(date_due)) > '0'  
 
AND (TO_DAYS(curdate())-TO_DAYS(date_due)) > '0'  
 
AND (TO_DAYS(curdate())-TO_DAYS(date_due)) < '7'
 
AND (TO_DAYS(curdate())-TO_DAYS(date_due)) < '7'
ORDER BY issues.date_due ASC  
+
ORDER BY iu.date_due ASC  
 
</pre>
 
</pre>
  

Versionen från 28 mars 2019 kl. 16.13

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 bt.frombranch, bt.tobranch, i.homebranch, i.itemcallnumber, i.barcode, b.title, b.author, bt.datesent
FROM branchtransfers bt
LEFT JOIN items i ON (bt.itemnumber = i.itemnumber)
LEFT JOIN biblio b ON (i.biblionumber = b.biblionumber)
WHERE bt.datesent <= DATE_SUB(CURDATE(),interval 2 week)
AND bt.datearrived IS NULL
AND i.itemlost NOT LIKE '4'
AND i.homebranch = <<HEMENHET|branches>>
GROUP BY bt.frombranch, bt.tobranch, i.homebranch, i.itemcallnumber, i.barcode, b.title, b.author, bt.datesent

De 50 mest lånade böckerna ur magasin som bör tas till öppen samling.

SELECT count(s.datetime) AS circs, b.title, b.author, i.barcode, i.itemcallnumber,i.datelastseen
FROM statistics s
LEFT JOIN items i ON (s.itemnumber=i.itemnumber)
LEFT JOIN biblio b ON (i.biblionumber=b.biblionumber)
WHERE DATE(s.datetime) > DATE_SUB(CURRENT_DATE(),INTERVAL 6 MONTH) 
AND DATE(s.datetime)<=CURRENT_DATE() 
AND s.itemnumber IS NOT NULL AND s.type = 'issue'
AND i.itype = <<Skriv item type|itemtypes>>
GROUP BY b.biblionumber 
ORDER BY circs DESC 
LIMIT 50

Låntagare med kö-böcker

SELECT bo.surname, 
       bo.firstname, 
       bo.phone, 
       bo.cardnumber, 
       iu.date_due, 
       bi.title, 
       bi.author, 
       it.itemcallnumber, 
       it.barcode, 
       it.homebranch, (TO_DAYS(curdate())-TO_DAYS( date_due)) AS 'days overdue' 
FROM reserves r
LEFT JOIN borrowers bo ON (bo.borrowernumber = r.borrowernumber) 
LEFT JOIN issues iu ON (iu.borrowernumber=bo.borrowernumber) 
LEFT JOIN items it ON (it.itemnumber=iu.itemnumber)
LEFT JOIN biblio bi ON (bi.biblionumber =it.biblionumber)	   
WHERE r.reservedate IS NOT NULL
AND date (r.reservedate) < DATE_SUB(CURRENT_DATE(),INTERVAL 1 DAY)
AND r.waitingdate IS NULL
AND (TO_DAYS(curdate())-TO_DAYS(date_due)) > '0' 
AND (TO_DAYS(curdate())-TO_DAYS(date_due)) < '7'
ORDER BY iu.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