Mysql
 sql >> Base de données >  >> RDS >> Mysql

Filtrer une table jointe

select 
    case when e.published and a.type not in('large','medium') then 'Met condition' else 'Not met condition' end conditions
    , count(distinct e.id) totals
    , group_concat(distinct e.id) event_ids
    , count(distinct e.id) * 100.0 / x.total_cnt percentage
from events e
join Attributes a on a.event_id = e.id
cross join (select count(*) as total_cnt from events) x
group by case when e.published and a.type not in('large','medium') then 'Met condition' else 'Not met condition' end, total_cnt

db<>violon ici