Skip to content Skip to sidebar Skip to footer

Sqlite : With Clouse Result Weird

Now i can implement sqlite3 3.8.4.3 within my android app, i found an awesome library name sqlcipher , :) and now here again i'm trying to implement recursive function within an a

Solution 1:

This query sorts the records only by the 2nd column, the level.

To specify the order of records at the same level, you have to add the appropriate column to the ORDER BY clause. In this case, this is probably the id_tree value, which you have to add to the SELECT clause so that it is available:

WITHRECURSIVE
under_alice(name,level,order_nr) AS (
  VALUES('1','0',0)
  UNIONALLSELECT tree.id_child, under_alice.level+1, tree.id_tree
    FROM tree, under_alice
   WHERE tree.id_boss=under_alice.name 
   ORDERBY2DESC, 3
)
SELECT substr('..........',1,level*3) || name FROM under_alice;

Post a Comment for "Sqlite : With Clouse Result Weird"