General X++ Development
How do I get the first matching record in X++?
How do I get the first matching record in X++?
1 answer
Write an answerUse firstOnly. If "first" means newest, oldest, highest, or lowest, pair it with order by.
SalesTable salesTable;
select firstOnly salesTable
order by salesTable.CreatedDateTime desc
where salesTable.CustAccount == 'US-001';Without an order by, "first" should not be treated as a business rule. If the order matters, make it explicit.
Know the solution?
Sign in to contribute an answer and build your community reputation.
Sign in to answer