SELECT datefield, sum(somefield) FROM table WHERE datafield BETWEEN ? AND ? GROUP BY datefield