sql >> Database >  >> RDS >> Mysql

Een samengevoegde tabel filteren

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<>fiddle hier



  1. SQL Server Management Studio (SSMS)

  2. Een veilig inlogscript maken in PHP en MySQL zonder HTTPS

  3. SQL Kan geen tabel maken (errno:150)

  4. SELECTEER IN in MySQL