display table in hierarcies

  • 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 🙂

  • I can't see your example. Can you post it another way?

    Brandie Tarvin, MCITP Database AdministratorLiveJournal Blog: http://brandietarvin.livejournal.com/[/url]On LinkedIn!, Google+, and Twitter.Freelance Writer: ShadowrunLatchkeys: Nevermore, Latchkeys: The Bootleg War, and Latchkeys: Roscoes in the Night are now available on Nook and Kindle.

  • this is the url to the image

  • The first thing I advise is taking a look at what you actually want mapped. It doesn't make sense to me.

    You want app3 stuff mapped to app4?

    The second thing I recommend is giving us the DDL for the table, an INSERT statement with sample data, and then post a typed example (rather than an image) of what you want the results of the query to look like (because that's not the same thing as the excel sheet image you posted).

    Then we can help you find your best options.

    In the meantime, I can recommend that you look into Row_Number() and Common Table Expressions.

    Brandie Tarvin, MCITP Database AdministratorLiveJournal Blog: http://brandietarvin.livejournal.com/[/url]On LinkedIn!, Google+, and Twitter.Freelance Writer: ShadowrunLatchkeys: Nevermore, Latchkeys: The Bootleg War, and Latchkeys: Roscoes in the Night are now available on Nook and Kindle.

  • 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

  • Glad I could help.

    Brandie Tarvin, MCITP Database AdministratorLiveJournal Blog: http://brandietarvin.livejournal.com/[/url]On LinkedIn!, Google+, and Twitter.Freelance Writer: ShadowrunLatchkeys: Nevermore, Latchkeys: The Bootleg War, and Latchkeys: Roscoes in the Night are now available on Nook and Kindle.

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply