not null as state1,
t2s2.id is not null as state2
from table1 t1
left join table2 t2s1 on t2.t_uui = t1.uuid and t2.state = 'state1'
left join table3 t2s2 on t2.t_uui = t1.uuid and t2.state = 'state2'
group by t1.uuid
MySQL такое должно пропустить. PgSQL ругнётся. Какая СУБД?
Select sums from (select distinct t1_id, status)
Обсуждают сегодня