I have this script, but would like to order by ID with parentID null desc.
"I tried order by id desc" but it dosent work. Can anybody help?
with product_hierarchy as
select top 1000 ID, ArtikelID, parentID, tekst ,1 lev , cast(id as varchar(max)) as path from
ar where parentid is null and artikelid = 1 order by id desc
select p.ID, p.ArtikelID, p.parentID, p.tekst ,ph.lev+1 , ph.path+'.'+ cast(p.id as varchar(max)) as path from H2581_Shop.ArtiklerKomment
ar p join product_hierarchy ph on ph.id = p.parentid
select * from product_hierarchy order by path
Please look at attrached file.
It shows my table.
I want to order the table so the order would be: