SELECT HIGH_PRIORITY 
	a.*, count(a.advert_stats_id) as sum_clicks 
FROM 
	(
	SELECT * 
	FROM 
		adverts_stats_clicks 
	WHERE 
		click_on LIKE 'www%' 
		AND click_from!='' 
		and click_from not like 'http%' 
		and ipfrom REGEXP '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' 
		AND advertisment_id IN (1786) 
		AND added_on >= '2013-05-12' AND added_on <= '2014-05-12' 
	) a
WHERE 
	a.domain_id IN (56,158,166,168,188,193,206,213,611,725,729) 		
group by 
	a.domain_id
	

SELECT HIGH_PRIORITY 
	a.*, count(a.banner_stats_id) as sum_clicks 
FROM 
	(
	SELECT * 
	FROM 
		banner_stats_clicks 
	WHERE 
		ipfrom REGEXP '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' 
		AND banner_id IN (805) 
		AND added_on >= '2013-05-12' AND added_on <= '2014-05-12' 
	) a
WHERE
	1 
	and a.domain_id IN (56,158,166,168,188,193,206,213,611,725,729) 		
group by 
	a.domain_id