Mysql
 sql >> Datenbank >  >> RDS >> Mysql

Operand sollte 1 Spalte enthalten - MySQL NOT IN

Es gibt immer das:

select *
from campaigns 
where id not in (
    select id_campaign from (
        select e.id_campaign as id_campaign, d.frequency, e.id
        from campaigns d left join served e on d.id = e.id_campaign
        where d.status = 'Active'
        group by e.id_campaign 
        having count(e.id) < d.frequency 
    )
)