[Koha-devel] Active borrowers report

Mike Hafen mdhafen at tech.washk12.org
Mon Jan 9 21:36:28 CET 2012


And now that I've actually tried that query, there are problems with it.
Here is a fixed version:

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

On Mon, Jan 9, 2012 at 1:31 PM, Galen Charlton <gmc at esilibrary.com> wrote:

> Hi,
>
>
> On 01/09/2012 03:30 PM, Mike Hafen wrote:
>
>> 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;
>>
>
> A UNION ALL is indeed a valid way to do it.
>
> Regards,
>
> Galen
> --
> Galen Charlton
> Director of Support and Implementation
> Equinox Software, Inc. / The Open Source Experts
> email:  gmc at esilibrary.com
> direct: +1 770-709-5581
> cell:   +1 404-984-4366
> skype:  gmcharlt
> web:    http://www.esilibrary.com/
> Supporting Koha and Evergreen: http://koha-community.org &
> http://evergreen-ils.org
>
> ______________________________**_________________
> Koha-devel mailing list
> Koha-devel at lists.koha-**community.org<Koha-devel at lists.koha-community.org>
> http://lists.koha-community.**org/cgi-bin/mailman/listinfo/**koha-devel<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/ <http://bugs.koha-community.org/>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: </pipermail/koha-devel/attachments/20120109/35d32767/attachment.htm>


More information about the Koha-devel mailing list