sql - Self Join to return distinct records in SQLite -
i trying retrieve distinct records using follow sql statement:
select count (*) from( select distinct pv1.docid, pv2.docid frequency pv1 inner join frequency pv2 on pv1.docid = pv2.docid , pv1.term="transactions" , pv2.term="world")x;
the schema is:
create table frequency ( docid varchar(255), term varchar(255), count int, primary key(docid, term);
i know there 187 docs containing term world , 26 containing transactions.
are trying this?
select count(distinct pv1.[docid]) frequency pv1 join frequency pv2 on pv2.[docid] = pv1.[docid] pv1.[term] = "transactions" , pv2.[term] = "world"
this returns count of unique docid's conditions stipulated.
Comments
Post a Comment