S
smat-consulting
Guest
What if you start with account-flag, and sort it by customer-ID. From there get the invoices within the date-range, and then get the store of the invoice header. If a customer is buying only at one store, that should work fine and might be faster (as results are in customer-ID order already and don't need to be sorted after being retrieved). Second requirement for this to be fast is that you do have an index on InvHeader with the customer_ID as first component and the the date as second. Another alternative might be: Since you don't have many stores, you could run through account-flag, then all relevant stores, and then invoices with given store_id and and customer_ID. Again, works only if index in invHeader has customer_ID and store_id as first and second component (in either order). Second assumption: you don't have a ton of customers with no invoices... (And you could try to with stores and account-flag in the query, but leave invHeader as third table) Well, just a thought... Good luck
Continue reading...
Continue reading...