I’m having problem with adding these two mysql query results. Can I get some help, please? What am I doing wrong?

```
$sql = "SELECT SUM('tcount') FROM ( SELECT
d1.id AS id1,
d2.id AS id2,
IF((d1.as1-d2.as1)=1,1,0) +
IF((d1.as1-d2.as2)=1,1,0) +
IF((d1.as1-d2.as3)=1,1,0) +
IF((d1.as1-d2.as4)=1,1,0) +
IF((d1.as2-d2.as1)=1,1,0) +
IF((d1.as2-d2.as2)=1,1,0) +
IF((d1.as2-d2.as3)=1,1,0) +
IF((d1.as2-d2.as4)=1,1,0) +
IF((d1.as3-d2.as1)=1,1,0) +
IF((d1.as3-d2.as2)=1,1,0) +
IF((d1.as3-d2.as3)=1,1,0) +
IF((d1.as3-d2.as4)=1,1,0) +
IF((d1.as4-d2.as1)=1,1,0) +
IF((d1.as4-d2.as2)=1,1,0) +
IF((d1.as4-d2.as3)=1,1,0) +
IF((d1.as4-d2.as4)=1,1,0) AS tcount
FROM astb AS d1 , astb AS d2
WHERE d1.id IS NOT NULL AND d2.id IS NOT NULL AND d1.id > d2.id;
UNION ALL
SELECT
d1.id AS id1,
d2.id AS id2,
IF((d1.as1-d2.as1)=-1,1,0) +
IF((d1.as1-d2.as2)=-1,1,0) +
IF((d1.as1-d2.as3)=-1,1,0) +
IF((d1.as1-d2.as4)=-1,1,0) +
IF((d1.as2-d2.as1)=-1,1,0) +
IF((d1.as2-d2.as2)=-1,1,0) +
IF((d1.as2-d2.as3)=-1,1,0) +
IF((d1.as2-d2.as4)=-1,1,0) +
IF((d1.as3-d2.as1)=-1,1,0) +
IF((d1.as3-d2.as2)=-1,1,0) +
IF((d1.as3-d2.as3)=-1,1,0) +
IF((d1.as3-d2.as4)=-1,1,0) +
IF((d1.as4-d2.as1)=-1,1,0) +
IF((d1.as4-d2.as2)=-1,1,0) +
IF((d1.as4-d2.as3)=-1,1,0) +
IF((d1.as4-d2.as4)=-1,1,0) AS tcount
FROM astb AS d1 , astb AS d2
WHERE d1.id IS NOT NULL AND d2.id IS NOT NULL AND d1.id > d2.id;) where d1.id = d2.id+1";
```

This is my sql fiddle. http://sqlfiddle.com/#!9/22179d/2

Thank you in advance!