It said to do a group by so I modified my query and now it says "Unknown column 'date' in 'having clause' ".
I have a date column and the table name in my query is correct. It probably doesnt matter but the date column is also set as a date data type, it is populated with data, and the data is in the correct format (2005-06-21).
Here's my modified query:
$query="SELECT name,COUNT(name) as count,SUM(amount) as sumamount FROM table GROUP BY name HAVING (date BETWEEN '$date1' AND '$date2') AND orders > 0";
Thanks for the help so far.