SORTING.

  • Thread starter Thread starter Fab
  • Start date Start date
F

Fab

Hello,

I have a table with a parent child relation within the table and need to
sort with the partent record then its child records. i.e.


id parent_id
1
34 1
55 1
66 1
2
101 2
287 2
666 2


Thanks.
 
If I assume that Parent_ID is blank if the record is the parent (so you only
have two levels).

ORDER BY Val(NZ(Parent_ID,ID)), ID

That only works as long as ParentID is less than ID. So the following more
complex statement might work for you.

ORDER BY Val(NZ(Parent_ID,ID)), Parent_ID, ID
 
Back
Top