[Koha] Reporting help

Gunilla Jensen Gunilla.Jensen at niwa.co.nz
Tue Sep 24 13:57:50 NZST 2013


Thanks to Tim Hannah at the New Zealand Ministry of Education, I have got a report that works with the following SQL:

SELECT  biblio.title, items.itemcallnumber, items.holdingbranch, items.homebranch, items.barcode, count(distinct items.holdingbranch)
FROM items
LEFT JOIN biblio ON items.biblionumber=biblio.biblionumber
WHERE (
       (items.holdingbranch = 'WELLINGTON')
    or (items.holdingbranch = <<Pick your branch|branches>>)
      )
GROUP BY biblio.title
HAVING COUNT(distinct items.holdingbranch)>1

Cheers,
Gunilla


-----Original Message-----
From: koha-bounces at lists.katipo.co.nz [mailto:koha-bounces at lists.katipo.co.nz] On Behalf Of Gunilla Jensen
Sent: Monday, 23 September 2013 2:38 p.m.
To: koha at lists.katipo.co.nz
Subject: [Koha] Reporting help

Hello all

NIWA Library are combining branch collections around New Zealand into one centralised in Wellington.  For deselection purposes I'm trying to create a report, so I can see what titles we have got duplicate items in Wellington and at other branches.  However, I'm not having much success with the SQL below.  I can't get the AND operator to work (e.g. WHERE holdingbranch = 'WELLINGTON' AND holdingbranch = 'CHRISTCH').  Instead I use IN(X,Y) but this operator uses 'OR' as default so I get all titles held both in Wellington and in Christchurch instead of just the titles that are held in both places.  Can anyone help me with this?

SELECT
  biblio.title,
  items.itemcallnumber,
  items.holdingbranch,
  items.homebranch,
  items.barcode
FROM items
LEFT JOIN biblio ON items.biblionumber=biblio.biblionumber
WHERE holdingbranch IN('WELLINGTON', 'CHRISTCH') ORDER BY biblio.title

Thank you,
Gunilla


Gunilla Jensen | Librarian (Technologies) NIWA -National Institute of Water and Atmospheric Research<http://niwa.co.nz/> Private Bag 19401, Kilbirnie, Wellington, 6241, NZ | 04-3860544 library at niwa.co.nz<mailto:library at niwa.co.nz>

--
Please consider the environment before printing this email.
NIWA is the trading name of the National Institute of Water & Atmospheric Research Ltd.
_______________________________________________
Koha mailing list  http://koha-community.org Koha at lists.katipo.co.nz http://lists.katipo.co.nz/mailman/listinfo/koha
--
Please consider the environment before printing this email.
NIWA is the trading name of the National Institute of Water & Atmospheric Research Ltd.


More information about the Koha mailing list