So the limitation is that you need to join them together, right? If you had an order and lines linked (e.g. by a Delayed link such as in PurchTable form), you would simply set FirstOnly for the datasource representing lines.
If you need to join the tables, you’re quite limited by AX version of SQL, namely the lack of support for subqueries. Maybe you can find a range usable in your situation (e.g. LineNum == 1). Maybe you will rather find all first lines (min(LineNum) group by ID), save them to a TempDB table and use that for filtering (exists join) lines in your original query. Or maybe you’ll find a better idea than I’m able on Friday evening. [:)]