From: Galen Charlton Date: Mon, 13 Jan 2020 18:59:11 +0000 (-0500) Subject: BookNet Canada export: fix incorrect counts X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=0f5c22b4156902ed25e50b4d9a127409974eabe1;p=contrib%2Fequinox.git BookNet Canada export: fix incorrect counts Various "COUNT(foo.id)" needed to become "COUNT(DISTINCT foo.id)" when gathering lending counts to avoid duplication of rows due to the outer joins in the query. Signed-off-by: Galen Charlton --- diff --git a/booknet/booknet_exporter.pl b/booknet/booknet_exporter.pl index 2d52b58..61c9293 100755 --- a/booknet/booknet_exporter.pl +++ b/booknet/booknet_exporter.pl @@ -276,12 +276,12 @@ sub get_lending_data { 'SELECT ssr.id ,ARRAY_TO_STRING(ssr.isbn,\';\') - ,COUNT(circs.id) - ,COUNT(renews.id) - ,COUNT(holds.id) - ,COUNT(ac.id) - ,COUNT(circs_out.id) - ,COUNT(onorder.id) + ,COUNT(DISTINCT circs.id) + ,COUNT(DISTINCT renews.id) + ,COUNT(DISTINCT holds.id) + ,COUNT(DISTINCT ac.id) + ,COUNT(DISTINCT circs_out.id) + ,COUNT(DISTINCT onorder.id) FROM (SELECT id, call_number FROM asset.copy WHERE circ_lib = ' . $org_id . ' AND deleted IS FALSE) ac LEFT JOIN