I have a table made after joining 2 tables, which produces a recursive table. Now I want to add an extra column CalculatedDiscount and fill empty discounts from higher to lower when lower groups are empty. So my idea, theoratically, is to look from the current group to the top: look at the parent group: has value: yes, the CalculatedDiscount is set to his discount. When no: look at his parent group, and so on and on, until at or not at base group.
What I expect is to have that calculated column filled with parents discount.
The ID and ParentID give the hierarchical datastructure. For code and further explanation look at the fiddle: https://dbfiddle.uk/cnSow2zY