I'd love to hear suggestion on how to do this in ebean:
Given a table transactions with columns: customer, store, transact_date, product, quantity, price
I'd like to find the latest transaction for each customer in a list of stores. The sql can be written as
SELECT a.* FROM transactions a
WHERE NOT EXISTS (SELECT 1 FROM transactions b WHERE b.customer=a.customer AND b.store=a.store AND b.transat_date>a.transact_date) and a.store in (?, ?, ?, ?)
My question is where to put the subquery for notExist and how to join to itself. Thanks for your help.
Buck