We wrote a query to do exactly this. While it was written for Oracle,
MySQL syntax should be similar. You'll need to input the same list of
site IDs into both IN clauses. The query will produce two duplicate
columns of site IDs, but you can just ignore one.
SELECT *
FROM (
SELECT DISTINCT(site_id)
FROM sakai_site
WHERE site_id IN ()
) a
LEFT OUTER JOIN (
SELECT s.site_id, TRUNC(SUM(c.file_size) / 1024 / 1024, 2) AS
megabytes
FROM sakai_site s
JOIN content_resource c
ON c.resource_id LIKE CONCAT(CONCAT('/group/', s.site_id), '/%')
WHERE s.site_id IN ()
GROUP BY s.site_id
) b
ON a.site_id = b.site_id
ORDER BY a.site_id asc;
Hope this helps you!
--
Brian Jones
Programmer/Analyst
Western Technology Services
Western University
bjon...@uwo.ca