Using MAX() in MySQL more efficiently -
I am trying to get all the email addresses that have ordered anything with category id of 10 But this month nothing has been ordered. If they have ordered the category id of any type this month, then I do not want to include them.
I am using this question but I do not think that it is very efficient, it has been going on for many years.
Select contact e-mail (order order maximum (order date) where o.customerID = commands.customerID) with latest order order where category id = 7 'contact e- Group latest order by mail & lt; = '2014-04-01 00:00:00' Is there a better way?
You do not need subquery if you already have order Can be referenced. Should do some work like this (has not been tested)
Select contact email, maximum order order (from order) as the latest order WHERE categoryID = 'Latest Order Ordering Customer ID by Group' & lt; = '2014-04-01 00:00:00' '
Comments
Post a Comment