@jkane - I’ll give your suggestion a try tonight. Need to clear my head and start over.
No worries. Let me know if you have any questions.
Just realized that I forgot to put that the sort column in my example is a concatenation of the other 3 fields.
Thinking way outside the box here…
Load what you need into a UD Table. The keys might work to store the header, Invoice, detail. Then the BAQ is an easy dump from there and you could mark the records as processed with a date in one of the date fields. It will require more code to load the UD Table in question, but the output should be easier.
For the sorting, can’t you just put the other subqueries into a subquery like this and then use the top query to sort on whichever field you want:
The query becomes:
The results become:
Maybe I’m missing something with this simple example.
It might just be me, but I find this sort of requirement the BAQ takes a lot longer to work out than just being able to write a SQL statement.