tsql - organize sql heirarchy -


i have following table:

id   son  roworder   technology 1     8     null       fa 8     0     null       fa 9     15    null       gr 15    0     null       gr 

i create sql query "order by" following order: technology, "father" (a record has son), son (the direct son of previous father" , update roworder column next time order these records sole based on roworder. ideas? thanks

if not want data change instead of storing data in row number use

select     id,    son,     technology,    isnull((select id table t2 t2.id = t1.son), 0) father,    row_number() on (order technology, father, son) rownumber     table t1  order     rownumber asc 

the functions isnull() , row_number() may change name depending on database using rough idea of should go for.


Comments

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -