select - Querying SQL for multiple records -
i have table containing information, , wish make select query retrieve wanted informations.
my table looks like,
column1 column2 column3 ... company1 doc1 company1 doc2 company1 doc3 company2 doc1 company2 doc3 company3 doc1 ...
so want is, select companies containing 3 documents. is, if compan1 contains doc1, doc2, doc3, select it. if contains doc2 , doc3, or else, not select it.
so overall, want overview of companies containing exact 3 documents.
hope gives sense :).
select column1 the_table column2 in ('doc1', 'doc2', 'doc3') group column1 having count(distinct column2) = 3;
Comments
Post a Comment