https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=28530

--- Comment #113 from Andrew Fuerste-Henry <[email protected]> ---
I found it helpful to have a query to count items per branch, taking into
account how many are checked out or in transit. I've been resting using the Ref
item type as there aren't any in the base KTD data so it's easy to set up
tests.

SELECT item_counts.*, transfer_incoming
FROM 
(
SELECT i.holdingbranch,
count(i.itemnumber) as count_by_holdingbranch_only,
sum(if(t.branchtransfer_id is null and i.onloan is null,1,0)) as available,
sum(if(i.onloan is not null,1,0)) as checked_out,
sum(if(t.branchtransfer_id is not null,1,0)) as transfered_away
FROM items i
LEFT JOIN branchtransfers t ON (i.itemnumber=t.itemnumber and t.datesent is not
null and t.datecancelled is null and t.datearrived is null)
WHERE itype='ref'
GROUP BY holdingbranch
) item_counts
LEFT JOIN
(
SELECT b.tobranch, count(b.branchtransfer_id) as transfer_incoming
FROM branchtransfers b
WHERE b.datesent is not null and b.datearrived is null and b.datecancelled is
null
GROUP BY tobranch
) incoming ON (item_counts.holdingbranch = incoming.tobranch)

-- 
You are receiving this mail because:
You are watching all bug changes.
_______________________________________________
Koha-bugs mailing list
[email protected]
https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-bugs
website : http://www.koha-community.org/
git : http://git.koha-community.org/
bugs : http://bugs.koha-community.org/

Reply via email to