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

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -