sql server 2008 - Creating a hierarchy group from one table column contain both parent and child hierarchy info -
i need creating hierarchy group 'using' data in event_role column in sample table create grouping structure below.
the 6 parent hierarchies
'speaker', 'coordinator', 'volunteer', 'instructor', 'attendee', 'registration'
and child hierarchies (or lower levels)
did not attend/yes attend attendee , not register/no reg/yes reg registration.
i have 100000+ rows create these hierarchy groups , have more groups , child hierarchies.
hierarchy groups
speaker coordinator volunteer instructor attendee--- **child(lv2)**-- did not attend/yes attend registration--**child(lv2)**---do not register/no reg/yes reg
i have create sample data in sql server
thank in advance!!
create table table1 ( participant_id int not null ,supporter_id int not null ,event_code varchar (50) ,event_role varchar (100) null ) insert table1 (participant_id,supporter_id,event_code,event_role) values ('234221','23536','leg_swi_1995','did not attend'); insert table1 (participant_id,supporter_id,event_code,event_role) values ('234221','23536','leg_swi_1995','yes reg'); insert table1 (participant_id,supporter_id,event_code,event_role) values ('234220','17238','leg_swi_1995','did not attend'); insert table1 (participant_id,supporter_id,event_code,event_role) values ('234220','17238','leg_swi_1995','yes reg'); insert table1 (participant_id,supporter_id,event_code,event_role) values ('234219','23532','leg_hat_1996','did not attend'); insert table1 (participant_id,supporter_id,event_code,event_role) values ('234219','23532','leg_hat_1996','yes reg'); insert table1 (participant_id,supporter_id,event_code,event_role) values ('234218','58195','leg_hat_1996','did not attend'); insert table1 (participant_id,supporter_id,event_code,event_role) values ('234218','58195','leg_hat_1996','yes reg'); insert table1 (participant_id,supporter_id,event_code,event_role) values ('234217','23494','leg_swi_1995','did not attend'); insert table1 (participant_id,supporter_id,event_code,event_role) values ('234217','23494','leg_swi_1995','yes reg'); insert table1 (participant_id,supporter_id,event_code,event_role) values ('234208','00442','leg_oxf_1998','yes attended'); insert table1 (participant_id,supporter_id,event_code,event_role) values ('234182','65306','swcm01','iscoordinator'); insert table1 (participant_id,supporter_id,event_code,event_role) values ('234182','65306','swcm01','no reg'); insert table1 (participant_id,supporter_id,event_code,event_role) values ('234152','22969','leg_hat_1996','iscoordinator'); insert table1 (participant_id,supporter_id,event_code,event_role) values ('234152','22969','leg_hat_1996','no reg'); insert table1 (participant_id,supporter_id,event_code,event_role) values ('234146','32672','leg_mar_01','iscoordinator'); insert table1 (participant_id,supporter_id,event_code,event_role) values ('234146','32672','leg_mar_01','no reg'); insert table1 (participant_id,supporter_id,event_code,event_role) values ('234123','47377','leg_oxf_1998','yes attended'); insert table1 (participant_id,supporter_id,event_code,event_role) values ('234122','38726','leg_oxf_1998','yes attended'); insert table1 (participant_id,supporter_id,event_code,event_role) values ('234121','50341','leg_bur_0000','yes attended'); insert table1 (participant_id,supporter_id,event_code,event_role) values ('218893','90409','semf091212','speaker'); insert table1 (participant_id,supporter_id,event_code,event_role) values ('218890','23749','rfseah091212','speaker'); insert table1 (participant_id,supporter_id,event_code,event_role) values ('218889','90387','seaj251112','speaker'); insert table1 (participant_id,supporter_id,event_code,event_role) values ('218884','65306','serb031212','speaker'); insert table1 (participant_id,supporter_id,event_code,event_role) values ('218874','58902','secw021212','speaker'); insert table1 (participant_id,supporter_id,event_code,event_role) values ('218231','50766','lm1301','do not register'); insert table1 (participant_id,supporter_id,event_code,event_role) values ('218221','73854','segf050912','speaker'); insert table1 (participant_id,supporter_id,event_code,event_role) values ('218218','28146','lm1301','do not register'); insert table1 (participant_id,supporter_id,event_code,event_role) values ('218211','95575','sedb220712','speaker'); insert table1 (participant_id,supporter_id,event_code,event_role) values ('217647','22632','gnr0001','do not register'); insert table1 (participant_id,supporter_id,event_code,event_role) values ('142470','08862','elon09','isvolunteer'); insert table1 (participant_id,supporter_id,event_code,event_role) values ('142469','01362','elon09','isvolunteer'); insert table1 (participant_id,supporter_id,event_code,event_role) values ('132899','92898','elon09','isvolunteer');
`
look sqlfiddlelink maybe helps friend. have created table group_eventrole hierarchy group or (hierarchy type in idea) , altered table1's event_role column int too.
the name event_role , name_parent parent of event_role
Comments
Post a Comment