View previous topic :: :: View next topic

Author 
Message 
revdpoel
New User
Joined: 01 Nov 2006 Posts: 56




Table T552 looks like this
Dagkey Automaat BBOkey SSPkey Number
1 AA 23 98 876
2 BB 23 66 21
3 BB 15 2 67
4 KL 44 2 32
BBOkey points to table T400, which has the attributes reknr and BBPkey.
This BBPkey points to table T300, which has an attribute partzaklcd. This attribute can have the value ‘P’ or ‘Z’.
SSPkey points to table T414, which also has the attributes reknr and BSPkey.
BSPkey points to table T416, which has an attribute partzaklcd. This attribute can have the value ‘P’ or ‘Z’.
When a BBOkey points to a value of reknr in T400 with a value of 2 it means it is not applicable. Let’s say this is BBOkey 23.
For that row we have to read T414 with the SSPkey
When a Savingskey points to a value of reknr in T414 with a value of 2 it means it is not applicable. Let’s say this Savingskey 2.
For that row we have to read T400 with the BBOkey
I have to count the numbers and divide them into partzaklcd.
Example 1:
Read row with dagkey 1.
BBOkey 23 points to reknr2 in T400. So for that row we have to read T414 with SSPkey 98. Let’s say bspkey in this T414 row points to a row in T416 where partzaklcd = ‘P’ then we have to count the number of 876 for ‘P’.
Read row with dagkey 3.
BBOkey 15 points to a reknr <> 2 in T400. So for that row we have to read T400 with BBOkey 15. Let’s say BBPkey in this T400 row points to a row in T300 where partzaklcd = ‘Z’ then we have to count the number of 67 for ‘Z’.
Suppose row 2 gives us a number of 21 for partzaklcd ‘P’ and row 2 gives us a number of 32 for partzaklcd ‘P’, then the result is
‘P’ 876+21+32 = 929
‘Z’ 67 

Back to top 




Rohit Umarjikar
Global Moderator
Joined: 21 Sep 2010 Posts: 1575 Location: NY,USA




I tried to understand so check below query,
Code: 
select a.number,count(*) as total_876_P
from T552 a,T414 b, T416 c, T400 d
where a.BBOKey = d.??
and d.reknr = 2
and b.bspkey = c.??
and c.partzaklcd = ‘P’
group by a.number
UNION
select a.number,count(*) as total_876_Z
from T552 a, T400 b, T300 c
where a.BBOKey = b.BBPkey??
and b.reknr <> 2
and b.bbpkey = c.??
and c.partzaklcd = ‘Z’
group by a.number 
Quote: 
Suppose row 2 gives us a number of 21 for partzaklcd ‘P’ and row 2 gives us a number of 32 for partzaklcd ‘P’, then the result is
‘P’ 876+21+32 = 929
‘Z’ 67 
Can you please explain this? 

Back to top 



