Additonal help needed on ciruclation report
The Circulation report that I requested help on is progressing, thanks to everyone who contributed help. This one is for daily circ but could also be adapted for monthly. I obviously am still having trouble with my Biographies (B) and Fiction (F). On this day, we had one biography and two fiction checked out. I have no idea where the other numbers are coming from. Currently my squl is as follows. I have cut and pasted and tried different variations that in my mind should work. So, I am back to have the collective eye tell me the obvious thing that I am missing. SQUL select substring(itemcallnumber,1,1) as 'Call# range', count(*) from items, statistics where statistics.itemnumber = items.itemnumber and type in ('issue', 'renew') and date(datetime) between '2009-07-09' and '2009-07-09' and itemcallnumber is not null and length(itemcallnumber) and substring(itemcallnumber,1,1) between '0' and '9' or substring(itemcallnumber,1,1) = 'F' or substring(itemcallnumber,1,1) = 'B' group by substring(itemcallnumber,1,1) This results in the following. Everything is fine but the F's and B's CIRC Total number of rows matching the (unlimited) query is 1. Call# range count(*) 0 1 1 1 7 1 B 145321 F 225423 Scotty Zollars Director of Library Services Labette Community College 200 S. 14th Parsons, KS 67357 620-820-1168 620-421-1469 FAX
between '2009-07-09' and '2009-07-09'
It doesn't make much sense to use BETWEEN with the same value. But your main problem is that you aren't selecting JOINed rows, you're selecting ALL the rows from the two tables. Try starting with the statistics table, then left-joining on the items table. That's because you don't want any rows from items except to extend the data found in statistics. Try this: SELECT DATE(datetime) AS date, substring(itemcallnumber,1,1) AS 'Call# range', count(*) AS count FROM statistics LEFT JOIN items USING (itemnumber) WHERE statistics.type IN ('issue', 'renew') AND YEAR(datetime) = 2009 AND MONTH(datetime) = 7 GROUP BY DATE(datetime), substring(itemcallnumber,1,1)
participants (2)
-
Joe Atzberger -
Scott Zollars