AnsweredAssumed Answered

SQL Question is FMPA14.

Question asked by cruiseqe2 on Jul 16, 2016
Latest reply on Jul 17, 2016 by siplus



I am trying to generate some sql that will return the last item in for each grouped set. I'm sure that I have not made myself clear, so I will give and example.


I have a table ORDERS and I wish to get the last ORDER for each customer.


I have written the following, and it works.


SELECT OrderCustomer, MAX(OrderDate)

  FROM Orders

  GROUP BY OrderCustomer


With me so far? However, I now need to bring out in the returned data the OrderContactName (text field) for the returned OrderDate.

I can't put this in as, because it is not a grouped field, it must have a 'function' applied to the data - such as MAX, MIN, COUNT etc.

I don't want any of these 'functions'.

I just want the OrderContactName that is associated with the returned record per OrderCustomer.


Any thoughts or solutions, All are welcome.