Select Unique Records In Sqlite
Consider a table results (id, key, value) where key is the Primary key. Sample data: id | key | value ----------------------- abc| source-1 | 20 abc| source-2 | 30 abc| source
Solution 1:
One way is to use GROUP BY and HAVING to produce a derived table with the desired id
s and then JOIN to it:
select results.*
from results
join (select id
from results
groupby id
having count(*) = 1
) as dt on results.id = dt.id
You could also use an IN if you don't like derived tables:
select *
from results
where id in (select id
from results
groupby id
having count(*) = 1
)
Post a Comment for "Select Unique Records In Sqlite"