- Product: Voyager
- Relevant for Installation Type: Multi-Tenant Direct, Dedicated-Direct, Local, TotalCare
How can we determine how many items we currently have checked out?
You can find how many items are currently charged out with this simple query that uses the CIRC_TRANSACTIONS table:
select count(*) from circ_transactions;
But your question is far more complicated than it might seem if you want more than just a count.
It's complicated by the fact that patrons can have multiple patron groups, with a barcode for each (so in other words, patrons with multiple active barcodes and groups (like a grad student who's also an employee and given staff privileges)). The CIRC_TRANSACTIONS table includes patron_group_id to determine which of a patron's groups was active for the transaction, as that controls circ policy like loan duration.
Also keep in mind item barcodes are optional (and in some situations patron barcodes may not exist), so query joins can be complex.
The following pass-through query, which retrieves items currently checked out is provided as an example:
, ( select min(patron_barcode)
where patron_id = ct.patron_id
and patron_group_id = ct.patron_group_id
--and barcode_status = 1 --Active
) as patron_barcode
, ct.charge_due_date as due_date
from circ_transactions ct
inner join item i on ct.item_id = i.item_id
left outer join item_barcode ib on i.item_id = ib.item_id and ib.barcode_status = 1 --Active
Constructing custom SQL queries by request and troubleshooting unexpected results from customer-created SQL queries falls outside the scope of Support. The above has been posted for informational purposes. Voyager-L and Developer Network are useful resources for finding helpful custom SQL or obtaining assistance from peers in troubleshooting custom queries.
- Article last edited: 08-Apr-2022