Here's my Query that does not work because it apparently violates the rules of the HAVING clause:
SELECT
COALESCE(Publisher.name, Affiliate.name) AS Publisher
,dbo.SumKeys(Item.id) AS ItemIDs
FROM
Item
INNER JOIN ItemAccountingStatus ON Item.item_accounting_status_id = ItemAccountingStatus.id
INNER JOIN Affiliate ON Item.affid = Affiliate.affid
INNER JOIN Currency AffiliateCurrency ON Affiliate.currency_id = AffiliateCurrency.id
INNER JOIN Campaign ON Item.pid = Campaign.pid
INNER JOIN CampaignStatus ON Campaign.campaign_status_id = CampaignStatus.id
LEFT OUTER JOIN Publisher ON Affiliate.affid = Publisher.affid
GROUP BY
COALESCE(Publisher.name, Affiliate.name)
,ItemAccountingStatus.name
,CampaignStatus.name
HAVING (
ItemAccountingStatus.name='default'
and CampaignStatus.name='Verified'
and Publisher='AdsMain LLC' -- THIS BREAKS THE QUERY
)
QUESTION: is there any way to do this?