[Koha-devel] Active borrowers report

Mike Hafen mdhafen at tech.washk12.org
Mon Jan 9 21:30:31 CET 2012


I've seen UNION used to join those two tables in queries.  I'm imaginning
something like:

SELECT YEAR(issuedate), MONTH(issuedate), categorycode, COUNT(DISTINCT
borrowernumber)
FROM (
  SELECT issuedate,categorycode,borrowernumber FROM old_issues
 UNION ALL
  SELECT issuedate,categorycode,borrowernumber FROM issues
 )
LEFT JOIN borrowers USING (borrowernumber)
GROUP BY YEAR(issuedate), MONTH(issuedate), categorycode;

But I'm no database expert, so use this with care.

On Mon, Jan 9, 2012 at 1:12 PM, Cab Vinton <bibliwho at gmail.com> wrote:

> A couple years ago Jesse Weaver came up with this report for active
> borrowers (i.e., patrons checking out materials):
>
>        SELECT YEAR(issuedate), MONTH(issuedate), categorycode,
> COUNT(DISTINCT borrowernumber)
>        FROM old_issues
>        LEFT JOIN borrowers USING (borrowernumber)
>        GROUP BY YEAR(issuedate), MONTH(issuedate), categorycode;
>
> I'm wondering if the caveat he notes is still true:
>
>        Because it uses old_issues, it won't include anything that's still
> checked out; getting
>        around that requires either ugly subqueries or running the report
> with old_issues
>        and issues and manually combining the results.
>
> Is there a relatively easy way to modify the report so it includes
> patrons who may still have items checked out?
>
> Thanks for any assistance!
>
> Cab Vinton, Director
> Sanbornton Public Library
> Sanbornton, NH
>
> "Politeness and consideration for others is like investing pennies and
> getting dollars back." Thomas Sowell
> _______________________________________________
> Koha-devel mailing list
> Koha-devel at lists.koha-community.org
> http://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel
> website : http://www.koha-community.org/
> git : http://git.koha-community.org/
> bugs : http://bugs.koha-community.org/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: </pipermail/koha-devel/attachments/20120109/540a2da4/attachment-0001.htm>


More information about the Koha-devel mailing list