BBO-key points to table T400, which has the attributes rek-nr and BBP-key.
This BBP-key points to table T300, which has an attribute part-zakl-cd. This attribute can have the value ‘P’ or ‘Z’.
SSP-key points to table T414, which also has the attributes rek-nr and BSP-key.
BSP-key points to table T416, which has an attribute part-zakl-cd. This attribute can have the value ‘P’ or ‘Z’.
When a BBO-key points to a value of rek-nr in T400 with a value of -2 it means it is not applicable. Let’s say this is BBO-key 23.
For that row we have to read T414 with the SSP-key
When a Savings-key points to a value of rek-nr in T414 with a value of -2 it means it is not applicable. Let’s say this Savings-key 2.
For that row we have to read T400 with the BBO-key
I have to count the numbers and divide them into part-zakl-cd.
Example 1:
Read row with dag-key 1.
BBO-key 23 points to reknr-2 in T400. So for that row we have to read T414 with SSP-key 98. Let’s say bsp-key in this T414 row points to a row in T416 where part-zakl-cd = ‘P’ then we have to count the number of 876 for ‘P’.
Read row with dag-key 3.
BBO-key 15 points to a reknr <> -2 in T400. So for that row we have to read T400 with BBO-key 15. Let’s say BBP-key in this T400 row points to a row in T300 where part-zakl-cd = ‘Z’ then we have to count the number of 67 for ‘Z’.
Suppose row 2 gives us a number of 21 for part-zakl-cd ‘P’ and row 2 gives us a number of 32 for part-zakl-cd ‘P’, then the result is
select a.number,count(*) as total_876_P
from T552 a,T414 b, T416 c, T400 d
where a.BBO-Key = d.??
and d.reknr = -2
and b.bsp-key = c.??
and c.part-zakl-cd = ‘P’
group by a.number
UNION
select a.number,count(*) as total_876_Z
from T552 a, T400 b, T300 c
where a.BBO-Key = b.BBP-key??
and b.reknr <> -2
and b.bbp-key = c.??
and c.part-zakl-cd = ‘Z’
group by a.number
Quote:
Suppose row 2 gives us a number of 21 for part-zakl-cd ‘P’ and row 2 gives us a number of 32 for part-zakl-cd ‘P’, then the result is