From 0f5c22b4156902ed25e50b4d9a127409974eabe1 Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Mon, 13 Jan 2020 13:59:11 -0500 Subject: [PATCH] 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 --- booknet/booknet_exporter.pl | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) 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 -- 2.11.0