本文介绍了如何编辑此查询,以便仅显示包含0个有效广告的广告组。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
SELECT p.partner_name AS Engine, ag.name AS Name,
CAST(ag.id AS varchar(20)) As InternalId,
ag.externalid AS ExternalId,
count(ad.id) AS ActiveAds
FROM t_sem_adgroup ag WITH (nolock)
JOIN t_sem_account ac WITH (nolock) ON ac.externalid = ag.extaccountid
JOIN t_sem_partner p WITH (nolock) ON p.id = ac.partnerid
JOIN t_sem_ad ad WITH (nolock) ON ad.adgroupid = ag.Id AND ad.status = 1
WHERE ag.status = 1
AND ca.status = 1
AND ac.status = 1
AND p.status = 1
AND p.id in (26)
GROUP BY p.partner_name, ag.name, ag.id, ag.externalid
HAVING count(ad.id) < 10
ORDER BY count(ad.id) ASC
我尝试了什么:
有人可以帮我解决这个非常简单的SQL查询吗?
如何编辑此查询,使其仅显示包含0个有效广告的广告组。
What I have tried:
Can somebody please help me with this pretty easy SQL query?
How do I edit this query so that it shows only adgroups with 0 active ads.
推荐答案
HAVING count(ad.id) = 0
这篇关于如何编辑此查询,以便仅显示包含0个有效广告的广告组。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!