|
dpais
Yak Posting Veteran
60 Posts |
Posted - 2010-06-09 : 10:15:48
|
| [code]parent Child grp output_neededpart1 Comp01 a 10 - output increments by 10 and does not increment where grp is the same.part1 Comp02 a 10part1 Comp03 NULL 20part1 Comp04 NULL 30part1 Comp05 b 40part1 Comp06 b 40part1 Comp07 NULL 50part1 Comp08 NULL 60part2 Comp09 NULL 10 - output resets when part2 changes.part2 Comp10 c 20part2 Comp11 c 20part2 Comp12 c 20part2 Comp13 NULL 30part2 Comp14 NULL 40part2 Comp15 d 50part2 Comp16 d 50part2 Comp17 NULL 60part2 Comp18 NULL 70[/code]i would like the output to be genereated by sql. thank you.DDL isselect 'part1' as parent,'Comp01' as child, 'a' as grpinto #temp1unionselect 'part1', 'Comp02', 'a'unionselect 'part1', 'Comp03', NULLunionselect 'part1', 'Comp04', NULLunionselect 'part1', 'Comp05', 'b'unionselect 'part1', 'Comp06', 'b'unionselect 'part1', 'Comp07', NULLunionselect 'part1', 'Comp08', NULLunionselect 'part2', 'Comp09', NULLunionselect 'part2', 'Comp10', 'c'unionselect 'part2', 'Comp11', 'c'unionselect 'part2', 'Comp12', 'c'unionselect 'part2', 'Comp13', NULLunionselect 'part2', 'Comp14', NULLunionselect 'part2', 'Comp15', 'd'unionselect 'part2', 'Comp16', 'd'unionselect 'part2', 'Comp17', NULLunionselect 'part2', 'Comp18', NULLI need the output column to be generated by SQL query. THis is Bill of material data - the output column are reference numbers on the Bill. the grp column denotes if the compnentns are alternates ... same grp's are alternate components. |
|