sql server 2012 - Grouping hierarchical data dynimacally -
i have following table structure:
id criteria01 criteria02 criteria03 ... criterian score
and need create procedure returns aggregated score results hierarchical criteria.
for example, if criteria
criteria01 -> criteria03 -> id
i need return data in following hierarchical format:
criteria03 score criteria01 score id score
or if have following sample data:
the result be:
explanations:
(hierarchical level 1) calculating average score each value in criteria01 or
select [criteria01] ,avg([score]) datasource group [criteria01]
(hierarchical level 2) calculating average score each value in criteria03 or
select [criteria03] ,avg([score]) datasource group [criteria03]
(hierarchical level 3) showing score id.
the above display how calculations done. , left match id rows parent criteria03 rows, , match criteria03 rows parent (criteria01) rows.
so, can have different hierarchical criteria , need return result hierarchical level column.
please, note not looking , not need working solution sample data have provided, in real case things litle bit more complicated.
what looking advice or idea approach of doing has been in such situation.
Comments
Post a Comment