Hi, here we are comparing gene table records like: first will take gene a and compare this with all genes a,b,c for example aa,ab,ac same will take b then ba,bb,bc so on.......
so here matching results are a nd b is 2 because matching records are 589,822 common gene terms for b c count is 1 because matching record 586 and for all other combinations it should be zero.
goterm gene auto
--------------------
589 a 1
822 a 2
478 a 3
586 b 4
589 b 5
600 c 6
586 c 7
822 b 8
Query:
select count(*),
x.gene,
x.ng
from (select t.gene,
v.gene as ng
from (select distinct gene
from gene) as t
cross join (select distinct gene from gene) as v) as x
left join (select (g.gene),(n.gene) as ng from gene g
join gene n on n.goterm=g.goterm where g.auto<n.auto ) as y on y.gene = x.ng
and y.ng = x.gene
group by x.gene,x.ng
Finally the output of the above query is:
count gene gene
1 a a
2 b a
1 c a
1 a b
1 b b
1 c b
1 a c
1 b c
1 c c
But the output must be:
count gene gene
0 a a
2 b a
0 c a
0 a b
0 b b
1 c b
0 a c
0 b c
0 c c