Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 display table in hierarcies

Author  Topic 

pelegk2
Aged Yak Warrior

723 Posts

Posted - 2012-09-11 : 05:34:02
i want to display a table in Hierarchie.
the thing is that the table dosen't have parent id or somthing like that.
attached is an example for before and after

10X :)

Mike Jackson
Starting Member

37 Posts

Posted - 2012-09-11 : 08:27:27
I don't see your examples, please repost.

Go to Top of Page

pelegk2
Aged Yak Warrior

723 Posts

Posted - 2012-09-11 : 08:34:15
http://s14.postimage.org/my8x11lnz/image.jpg
Go to Top of Page

pelegk2
Aged Yak Warrior

723 Posts

Posted - 2012-09-11 : 08:58:09
solved
select CASE WHEN MIN(t.r) = 1 then t.name1
ELSE ''
END as name1,
t.name2, t.name3, sum(t.sum1), sum(t.sum2)
from (select *, ROW_NUMBER() over(partition by name1 order by name1) r
from #tbl1) as t
group by t.name1, t.name2, t.name3
Go to Top of Page
   

- Advertisement -