• PSB - Sunday, February 26, 2017 8:28 PM

    Any help will be appreciated..

    We need to redo your schema as it makes no sense. By definition, a table has to have a key, but there is no way this stuff can have a key, because everything is nullable. There is no such thing as a generic “id†in RDBMS. Why do you think that I hundred Chinese characters is a good design for identifiers?

    ROLLUP is both a verb and a reserved word in SQL. It is not an entity or the valid name of any table. Likewise RESULT is too generic to ever be a valid entity name. However, more important, the effective two tables are redundant. Please read what Chris Date and Dave McGovern have to say about what a horrible thing it is.

    Why are you still using the old Sybase notation for insertions? Microsoft has had ANSI/ISO standard syntax for years.

    You need to get a copy of my “Trees and Hierarchies in SQL for Smarties†(ISBN 978–1–55860–920–4) and read chapter 4.7 where I work this problem out in detail. No, I am not going to post a few thousand words for you on a forum.

    To get you started look up the nested set model for trees; what you are doing is called an adjacency list model, and it is the worst way to model any sort of hierarchy in SQL.

    Please post DDL and follow ANSI/ISO standards when asking for help.