sql for rollup stats in the dspace database
A) Find all the item handles that belong to a community with a community id of 4
SELECT handle.handle FROM community2item, handle WHERE community2item.item_id = handle.resource_id AND handle.resource_type_id = 2 AND community2item.community_id = 4B) Turning a community handle into a resource id (community id)
SELECT handle.resource_id FROM handle WHERE handle=125 AND resource_type_id=4;resource_id
-------------
4
Note: resource_type_id=4 means community.
C) Substitute B into A -> Item handles in terms of community handle
SELECT count (handle) FROM community2item, handle WHERE community2item.item_id = handle.resource_id AND handle.resource_type_id = 2 AND community2item.community_id = (SELECT handle.resource_id FROM handle WHERE handle=125 AND resource_type_id=4);Note: resource_type_id=2 means item.