I have data like:
id,type,id2
1,a,100
2,a,100
3,c,
4,a,101
5,a,101
6,b,102
7,b,102
8,b,102
9,b,103
10,b,103
11,b,103
12,d,104
13,d,104
14,d,104
15,d,104
16,e,
17,c,105
18,c,105
What I am trying to do is to get the output:
a=2
b=2
c=2
d=1
e=1
So, this is essentially a count of the number of 'type' where id2 are the same. In the above data,
Count of (a=2) is
id 1 and 2 are type 'a' and have id2=100
id 4 and 5 are type 'a' and have id2=101
Count of (b=2) is
id 6,7 and 8 are type 'b' and have id2=102
id 9,10 and 11 are type 'b' and have id2=103
Count of (c=2) is
id 3 is type 'c' and has no id2
id 17 and 18 are type 'c' and have id2=105
Count of (d=1) is
id 12,13,14 and 15 are type 'd' and have id2=104
Count of (e=1) is
id 16 is type 'e' and has no id2
and a final total of 8, which is 2+2+2+1+1
I can't figure out the search required. Note that all types may or may not have id2 and the duplication of id2 can be up to 20 instances of the same id2.
... View more