select * from (select s_id, ts, count(id) as num_dis_firm from iiabmdb.with_exp_result where ts > 0 group by s_id, ts) as a where a.num_dis_firm > 3; select * from iiabmdb.with_exp_result where s_id = '54170'; SELECT * FROM iiabmdb.with_exp_sample where id='54170'; SELECT * FROM iiabmdb.with_exp_experiment where id='1084'; SELECT max(id) FROM iiabmdb.with_exp_sample; select * from (select s_id, id_firm, id_product, ts, count(id) as num_dup from iiabmdb.with_exp_result where ts > 0 group by s_id, id_firm, id_product, ts) as a where a.num_dup > 1;