fixes pgsql error for counting order per user