Chose the highest value
Posted on 2011-04-28
I am trying to find customers with thier last day of purchase and current balance below 1000 and this is my query
(c.reg_timestamp) BETWEEN '2011-04-01 00:00:00' AND '2011-04-15 23:59:59' AND o.current_playchips < 10000
ORDER BY u.USERID ASC , c.reg_timestamp DESC
the problem is this can generate 3 results for some customers and I need the last last date they purchased so is there anyway that I can get the HIGHEST c.reg_timestamp or time stamp in this where clause also only the last date the customer has purchased? c.reg_timestamp iis in date format so I hope there is a function which can select the highest date among more than 1 results per customer.
Thanks for the hielp