Below is a snippet of a table I want to query (sorted by user_id, choice, type):
I want to get a count of all the records where a SINGLE user made the same "choice" for both "type 1" and "type 2".
In the example above, the relevant rows would be:
So, the record count I would want returned would be 6 (12 is okay too - I can just divide it by two).
Code:
id user type choice
1 12345 1 1
2 12345 2 2
3 12345 1 4
4 12345 2 4
5 12345 2 6
6 12345 1 9
7 12345 2 9
8 12345 1 11
9 12345 1 13
10 12345 2 13
11 67890 1 1
12 67890 2 1
13 67890 1 2
14 67890 2 3
15 67890 1 4
16 67890 2 4
17 67890 1 7
18 67890 2 7
19 67890 1 11
20 67890 2 13
In the example above, the relevant rows would be:
Code:
id user type choice
3 12345 1 4
4 12345 2 4
6 12345 1 9
7 12345 2 9
9 12345 1 13
10 12345 2 13
11 67890 1 1
12 67890 2 1
15 67890 1 4
16 67890 2 4
17 67890 1 7
18 67890 2 7