select count(*) as result
from cms_items i, cms_bundles b
where i.item_id = b.bundle_id
and i.type_id is null
select count(*) as result
from cms_items i, cms_pages p
where i.item_id = p.item_id
and i.type_id is null
and i.parent_id is not null
select count(*) as result
from cms_items i, cms_bundles b
where i.item_id = b.bundle_id
and i.section_id is null
select count(*) as result
from cms_items i, cms_pages p
where i.item_id = p.item_id
and i.section_id is null
and (i.parent_id is not null or i.type_id is not null)
select count(*) as result
from cms_items i, cms_pages p
where i.item_id = p.item_id
and i.parent_id is not null
and i.type_id is not null
and not exists (select 1 from cms_bundles where bundle_id = parent_id)
select count(*) as result
from cms_items i, cms_bundles b
where i.item_id = b.bundle_id
and not exists (select 1 from cms_folders where folder_id = parent_id)
select count(*) as result
from (
select count(*) as count, parent_id, name
from cms_items i, cms_bundles b
where i.item_id = b.bundle_id
and version in ('live', 'draft')
group by parent_id, name
) sub where count != 1
select count(*) as result
from (
select count(*) as count, parent_id, language
from cms_items i, cms_bundles b
where i.parent_id = b.bundle_id
and version in ('live', 'draft')
group by parent_id, language
) sub where count != 1
select count(*) as result
from portlets
where not exists (select 1 from object_context where object_id = portlet_id)