when i execute that it give the following result
A,B 1
B,C 2
A,B,C 1
A,B,D 1
D,E 0
D,F,H 0
last two reuslts are wrong ,
1. as D is null and e has the value 4 in the table x so the result should be 4
2. as D is null and f is null too in the table x so the result should be the value of H ie 6