SQLITE: Select row ID based on only when the column all the values are same
Edit


  I should not get the result of ttid 5 because it has status as
  'preparing'. I should get ttids results only when all the statuses are
  'done'.


To get only the ones where done is found twice and no other statuses are found:

SELECT tb,  tbid, ttid,status 
FROM  test t1
WHERE status = 'done'
AND NOT EXISTS(SELECT * FROM test t2 where t2.status != 'done' and t1.ttid = t2.ttid)
GROUP BY  tb,tbid,ttid,status
HAVING COUNT(*) &gt; 1;


DB-Fiddle

Or

SELECT ttid,status 
FROM test t1
WHERE status = 'done'  
AND NOT EXISTS(SELECT * FROM test t2 where t2.status != 'done' and t1.ttid = t2.ttid)
GROUP BY  ttid,status
HAVING COUNT(*) &gt; 1;


DB-Fiddle

The reasoning for adding it to the group by or applying a function:

if tb or tbid can be different for the same 'done' status and the same ttid, which one do you choose? Do you choose the smallest, the biggest, ...?

An example of what happens if this is true and it is not added to a group by or function:

DB-Fiddle that fails