SQL Queries - CAST Knowledge Base - Queries on objects - How to get the Number of objects per analysis units

Purpose of Query

This query gives you the number of objects per Analysis Unit

Applicable CAST Version

ReleaseYes/No
8.3.x
8.2.x
8.1.x
8.0.x
7.3.x

Applicable RDBMS

RDBMSYes/No
Oracle Server
Microsoft SQL Server
CSS2

Query for CSS, Oracle, SQL Server

SELECT    mau.object_id   AS "Analysis Unit ID", 
          mau.object_name AS "Analysis Unit Name", 
          cdf.field_value AS "Analysis Unit UUID", 
          Count(1) AS "Number Of Objects"
FROM      <mngt db>.maint_analysisunits mau 
JOIN      <mngt db>.cms_dynamicfields cdf 
ON        cdf.object_id = mau.object_id 
LEFT JOIN <local db>.pmc_subsets ps 
ON        ps.subset_name LIKE 'CMS_PRO__' 
                    || cdf.field_value 
LEFT JOIN <local db>.pmc_subset_objects pso 
ON        pso.subset_id = ps.subset_id 
LEFT JOIN <local db>.objpro op 
ON        op.idpro = pso.object_id 
LEFT JOIN <local db>.keys kp 
ON        kp.idkey = op.idpro 
LEFT JOIN <local db>.keys k 
ON        k.idkey = op.idobj 
LEFT JOIN <local db>.typ t 
ON        t.idtyp = k.objtyp 
WHERE     cdf.field_guid = 'entry' 
AND       cdf.entity_guid LIKE '%AnalysisUnit%' 
GROUP BY  mau.object_id, 
          mau.object_name, 
          cdf.field_value

Query result example

Analysis Unit IDAnalysis Unit NameAnalysis Unit UUIDNumber Of Objects
31621HTML5uuid:29cd07d5-579a-4929-a5f6-89a7c80a6ccc208
31617BusinessHelloWorlduuid:6623aa3f-62ba-4652-b58b-eefaee6018a5850

Related Pages