SEARCH THE COMMUNITY

Find an existing answer

3 results for “order by”

CommunityHow do I use `order by` in an X++ select statement?How do I use order by in an X++ select statement?CommunityD365FO X++ select firstOnly with order by: how to guarantee deterministic row and verify generated SQLIn Dynamics 365 Finance and Operations, I’m using X++ statements like: ```x++ MyTable t; select firstOnly t from t where t.Status == Status::Open order by t.CreatedDateTime desc; ``` Sometimes users still report inconsistent rows between runs/environments. I suspectArticleD365FO X++: Why `firstOnly` can still return the wrong row unless you make the ordering explicit`firstOnly` is a common shortcut in D365FO, but it does not by itself make the returned row deterministic. This article shows how to combine `firstOnly`, `order by`, and the right query shape so you get the record you actually meant to fetch.