Hi guys,
want some help using a CTE to generate data using recursive SQL - input data in table A to be transformed into table B shown below
Table A
Instru_id_index instru_id_name instru_id_constit con_name weight
56 INDEX A 23 A 25
56 INDEX A 24 B 25
56 INDEX A 25 C 25
56 INDEX A 57 INDEX B 25
57 INDEX B 31 D 33
57 INDEX B 32 E 33
57 INDEX B 33 F 33
(Logic should be recursive in order to be able to handle multi-level, not just level 2.)
Table B
Instru_id_index instru_id_name instru_id_constit constit_name weight
56 INDEX A 23 A 25
56 INDEX A 24 B 25
56 INDEX A 25 C 25
56 INDEX A 31 D 8.3
56 INDEX A 32 E 8.3
56 INDEX A 33 F 8.3
57 INDEX B 31 D 3357 INDEX B 32 E 33
57 INDEX B 33 F 33
how can I write a simple CTE construct to display the data in table B - How can i calculate the values of weights as 8.3 respectively - calculate these without changing the structure of the tables.
Can I do this in a CTE