select username, count(distinct product) from events where username in $user_string and gmtdatetime >= '$min_date' and gmtdatetime < '$max_date' group by username;