SELECT CUST_NO, STOCK_NO, MAX(DOC_DATE), DOC_TYPE, DOC_NO, ; (NET / QTY) AS UNIT_RATE, SUM(NET) AS TOT_NET ; FROM t_invch ; INTO CURSOR inv_cur ; GROUP BY CUST_NO, STOCK_NOWith this, I got the total sell and last transaction date correctly. But other details like DOC_TYPE, DOC_DATE etc. of the last record, not of the last transaction date. What should be the proper SQL for this query?