Subject | Re: joins in sql |
---|---|
Author | harri007et <harri@uninet.ee> |
Post date | 2003-01-07T18:54:10Z |
Hi Luc!
count(distinct F.ID) etc. for simlicity as they were correct.
Also removed "where" part.
Table2->Table3->Table1 are related like master-detail-subdetail,
also Table2(master) has direct link to Table1(subdetail).
Each table has it's own filter.
I realized now, that what I was trying to do is very simple, but
impossible inside ONE query (just tried to save some connection
time).
Thanks,
Harri
>> SELECT COUNT(A.STATUS), SUM(A.STATUS)I removed all other "select" parts - count(distinct(E.ID),
>> 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
> 1. Each record from table A that has more than one
> corresponding entry in any of the joined tables will
> be counted several times, too.
>(What are the joins for anyway???)
count(distinct F.ID) etc. for simlicity as they were correct.
Also removed "where" part.
Table2->Table3->Table1 are related like master-detail-subdetail,
also Table2(master) has direct link to Table1(subdetail).
Each table has it's own filter.
I realized now, that what I was trying to do is very simple, but
impossible inside ONE query (just tried to save some connection
time).
Thanks,
Harri