IIabm/SQL_export_high_risk_settin...

17 lines
846 B
SQL

select distinct s_id from iiabmdb.without_exp_result where ts > 0;
select s_id, max(ts) as max_ts from iiabmdb.without_exp_result where ts > 0 group by s_id order by max_ts;
select e_id, count(id) as count, max(max_ts) as max_max_ts from iiabmdb.without_exp_sample as a
inner join (select s_id, max(ts) as max_ts from iiabmdb.without_exp_result where ts > 0 group by s_id) as b
on a.id = b.s_id
group by e_id
order by count desc;
select e_id, count, max_max_ts, dct_lst_init_remove_firm_prod from iiabmdb.without_exp_experiment as a
inner join
(select e_id, count(id) as count, max(max_ts) as max_max_ts from iiabmdb.without_exp_sample as a
inner join (select s_id, max(ts) as max_ts from iiabmdb.without_exp_result where ts > 0 group by s_id) as b
on a.id = b.s_id
group by e_id) as b
on a.id = b.e_id
where count >= 9
order by count desc;