SELECT sape_sites site sape_pages level Count DISTINCT sape_pages id A

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
SELECT
sape_sites.site,
sape_pages.level,
Count( DISTINCT sape_pages.id) AS num,
sum(sape_pages_block.`status`) AS coublock
FROM
sape_pages ,
sape_sites ,
sape_pages_block
WHERE sape_sites.id=sape_pages.site
AND sape_pages_block.page_id = sape_pages.id
AND sape_pages_block.`status`=1
GROUP BY sape_pages.site, sape_pages.level