Hello,
I have modified a query I found on the web to add the details I want and it returns the data you're interested in
SELECT
"Get Names"."site" AS "Site Name",
MAX("Get Names"."user_quota") AS "User Quota",
ROUND(MAX("Get Names"."storage_quota")/(1000*1000*1000),2) AS "Storage Quota (GB)",
ROUND(SUM("Get Names"."size")/(1000*1000*1000),2) AS "Storage Used (GB)",
CONCAT(ROUND(SUM("Get Names"."size")/MAX("Get Names"."storage_quota")*100,2),'%') AS "Percentage Used (%)"
FROM (
(
select workbooks.id as id, workbooks.created_at as created_at,
workbooks.owner_name as owner_name, workbooks.domain_name as domain,
workbooks.project_name as project, workbooks.project_id as project_id,
workbooks.workbook_url as url,workbooks.name,size,'workbook' as type, NULL as last_access_time,
_sites.name as site, _sites.url_namespace as site_id,
sites.user_quota, sites.storage_quota
from _workbooks workbooks, _sites, sites
where _sites.id = workbooks.site_id
and _sites.id = sites.id
)
union
(
select datasources.id as id, datasources.created_at as created_at,
datasources.owner_name as owner_name, datasources.domain_name as domain,
datasources.project_name as project, datasources.project_id as project_id,
datasources.datasource_url as url,datasources.name,size,'datasource' as type, last_access_time,
_sites.name as site, _sites.url_namespace as site_id,
sites.user_quota, sites.storage_quota
from _datasources datasources, _sites, _datasources_stats datasources_stats, sites
where _sites.id = datasources.site_id
and datasources.id = datasources_stats.datasource_id
and _sites.id = sites.id
)
) "Get Names"
LEFT JOIN "public"."extracts" "Data Source Extracts" ON ("Get Names"."id" = "Data Source Extracts"."datasource_id")
LEFT JOIN "public"."extracts" "Workbook Extracts" ON ("Get Names"."id" = "Workbook Extracts"."workbook_id")
group by "site"
order by 1
9 answers