SELECT room, MAX(res_date) AS max_date ; FROM mycurs1 ; GROUP BY 1 ; INTO CURSOR crsMaxRes * SELECT * FROM mycurs1 ; WHERE room + res_date IN ( ; SELECT room + max_date ; FROM crsMaxRes ) * or SELECT mc1.* FROM mycurs1 mc1 ; JOIN crsMaxRes mr ON mr.room = mc1.room ; AND mr.max_date = mc1.res_date>I combine two fields from the same table into one field (with the help from Fabio and Sergey in another thread).
>select * from MYCURS1 where PK_VALUE = MyFunc(ROOM) into cursor MYCURS2 > >Function MyFunc >lparameter tcRoomNum >local array laKeys[1] >select top 1 RESER_PK, END_TIME from MYCURS1 ; >where ROOM == tcRoomNum order by END_TIME descending into array laKeys >IF _tally > 0 > RETURN laKeys[1] >ELSE > RETURN 0 >endif >RETURN >>