Fixed SQL queries for getEmailsByProductsOrdered and getTotalEmailsByProductsOrdered
(issue #742)