<div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div link="blue" vlink="purple" lang="EN-US"><div><span style="color: black;" lang="EN">between '2009-07-09' and '2009-07-09'</span></div>
</div></blockquote><div><br>It doesn't make much sense to use BETWEEN with the same value. <br><br>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. <br>
<br>Try this:<br></div><br style="font-family: courier new,monospace;"></div><span style="color: black; font-family: courier new,monospace;" lang="EN">SELECT <br></span><span style="color: black; font-family: courier new,monospace;" lang="EN"> DATE(</span><span style="color: black; font-family: courier new,monospace;" lang="EN">datetime) AS date,</span><br>
<span style="color: black; font-family: courier new,monospace;" lang="EN"> substring(itemcallnumber,1,1) AS 'Call# range', </span><br><span style="color: black; font-family: courier new,monospace;" lang="EN"> count(*) AS count<br>
FROM statistics
<br>LEFT JOIN items USING (</span><span style="color: black; font-family: courier new,monospace;" lang="EN">itemnumber)</span><br><span style="color: black; font-family: courier new,monospace;" lang="EN">WHERE statistics.type IN ('issue', 'renew')
<br>AND YEAR(datetime) = 2009<br>AND MONTH</span><span style="color: black; font-family: courier new,monospace;" lang="EN">(</span><span style="color: black; font-family: courier new,monospace;" lang="EN">datetime) = 7<br>
</span><span style="color: black; font-family: courier new,monospace;" lang="EN"></span><span style="color: black; font-family: courier new,monospace;" lang="EN">GROUP BY<br></span><span style="color: black; font-family: courier new,monospace;" lang="EN"> DATE(datetime),</span><br>
<span style="color: black; font-family: courier new,monospace;" lang="EN"></span><span style="color: black; font-family: courier new,monospace;" lang="EN"> substring(itemcallnumber,1,1)</span>