I am struggling with a problem and can't seem to wrap my head around it.

I have 2 tables.

**KPA**

Datafields

Perf_KPA_ID (

**Primary key**)

Emp_ID

KPA_ID

**KPA_KPI**

Datafields

ID (

**Primary key**)

Perf_KPA_ID

KPI

Weight

Result

The entries looks like this.

**KPA Table**

1__EMP1__KPA1

2__Emp1__KPA2

3__Emp2__KPA1

**KPA_KPI**

1__1__KPI1__5__1

2__1__KPI2__10__0

3__1__KPI3__5__2

4__2__KPI4__5__3

5__2__KPI5__5__0

Now what I want to do is the following:

If the

**Result**is

**0**and the Weight is <

**5**then the

**Weight**of that KPI must be divided into the KPI's where the Perf_KPA_ID is the

**same**and the

**result is not 0**and the Weight of that KPI must become

**0**

If the

**Result**is

**0**and the Weight is >

**5**then the

**Weight**of that KPI must be divided into all the KPI's where the Emp_ID is the same in this case EMP1 and the result of any KPI's in that KPA_KPI table is not 0 and the Weight of that KPI must become

**0**

Any assistance will be greatly appreciated.