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 <g...@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: g...@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-de...@lists.koha-**community.org<Koha-devel@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/> >
_______________________________________________ Koha-devel mailing list Koha-devel@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/