Click to See Complete Forum and Search --> : How to query for words appearing in ONLY one doc


cy163
April 23rd, 2009, 09:56 AM
Hello ALL,

I have a table like



tlb

ClassID Class Word Freq
1 Sports basketball 3
1 Sports Football 2
1 Sports Volleyball 3

2 Education Basketball 2
2 Education Music 1

3 Art Picture 3
3 Art Football 3

I would like to find words which are unique for classes(i.e., words which appear only in one class), e.g.




Sports Volleyball
Education Music
Art Picture

I figure out the following query statement



SELECT ID, Class, Word FROM tlb GROUP BY Word HAVING COUNT(Class) = 1;

but i am not sure. please help me.