Subject | Re: [firebird-support] Re: wrong ordering in WITH RECURSIVE query |
---|---|
Author | Richard Damon |
Post date | 2019-04-16T16:19:19Z |
On Apr 16, 2019, at 4:40 AM, respektive@... [firebird-support] <firebird-support@yahoogroups.com> wrote:It sounds like you are forgetting that in SQL, the order of rows is considered unimportant unless there is an explicit order specified AT THAT QUERY (and not in a sub-query used to build that query). That is the nature of the language. If you want the rows in a particular order, then you need to generate something that give it that order.Hi, thank you for replyBut this ordering totaly damage the tree structureBecause PORADI is only relative to parent node, so all child nodes starting with 1If I change the query as you recommend, the set is sorted in way1. all first nodes2. all second nodes3. all third nodes....Any other advices??Thank you,TomasAny order outside that rule is just a coincidence.For instance, a sort code for the 3rd node below the 2nd node below node 1 could be 1.0203 (assuming that no node has more than 99 children). Or, if no node has more than 26 children, something like ABC