I have this simple (NON PRACTICAL) table
STUDENTID SERVICE
1 a
1 b
1 c
1 d
1 e
2 a
2 b
2 c
2 d
2 e
3 a
3 b
3 c
4 a
4 f
5 a
5 d
6 f
6 g
7 a
7 b
7 c
7 d
7 e
8 a
8 b
8 c
8 d
8 e
I want to tabulate certain information for instance.
How many students have signed up for service 'a' and service 'b' alone.
How many students have signed up for service 'a' and service 'c' alone.
How many students have signed up for service 'a' and service 'd' alone. etc.
or
How many students have signed up for service 'a' and one other service other than 'a'.
How many students have signed up for service 'b' and two other services other than 'b'.
The number of services might change in the future but that's okay for now.
this is what i have right now and it's not working.
--want to return number of students who have signed up for a and 1 any other service
select COUNT(STUDENTID), service from table
group by service where service = 'a' and studentid in
(select studentid from table group by STUDENTID having COUNT(service) = 2)