SELECT 000000 AS clt_order, ; >MIN(date) AS firstdate, ; >clt_code AS ccode ; >FROM invoice ; >INTO TABLE inv_temp1 ; >GROUP BY 3 ; >ORDER BY 2 > >* at this point you have a table with oldest invoice >* for each customer, sorted by date (the table name >* really should be a unique name that will not conflict >* with any other user) > >* make the order usable in the next SQL SELECT >SELECT inv_temp1 >REPLACE ALL clt_order WITH RECNO() > >* now do the final select >SELECT date, clt_code ; ><b>FROM invoice, inv_temp1 ; >WHERE clt_code = ccode ;</b> >ORDER BY temp1.clt_order, dateNot very elegant, but it does the job. Others may have a simpler way, but I can't think of it.