Subject joins in sql
Author harri007et <harri@uninet.ee>
Hi!

Given the following query, how are the count(A.STATUS) and
sum(A.STATUS) really calculated?

SELECT COUNT(A.STATUS), SUM(A.STATUS)
FROM TABLE1 A
JOIN TABLE2 B ON B.L_ID = A.O_ID
LEFT OUTER JOIN TABLE3 C ON C.O_ID = B.L_ID
LEFT OUTER JOIN TABLE1 D ON D.O_ID = B.L_ID
LEFT OUTER JOIN TABLE3 E ON E.ID = A.OS_ID
LEFT OUTER JOIN TABLE1 F ON F.OS_ID = E.ID

(Table1 has 1152 rows, column STATUS is type integer and has
1049 "0"-s and 76 "1"-s, query result is 16036, 1185)

What should I do to get "correct" results?

thanks,
Harri