Opscenter custom script help !
Oh powerful SQL query experts, please help me with my conumdrum...
I have written the following query to produce a list of current NBU clients hand how much data is protected in a given month by week including the number of jobs ran of a given schedule. When i run the script though the data is grossly larger then actuals ... what am i doing wrong?
SELECT
domain_MasterServer.friendlyName as "Master Server",
domain_JobArchive.clientName as "Client Name",
lookup_PolicyType.name as "Policy Type" ,
domain_JobArchive.scheduleName as "Schedule",
coalesce(CAST(SUM(domain_JobArchive.preSISSize)/1024/1024/1024 AS NUMERIC (20,0)),0) AS "GB",
(count(distinct domain_JobArchive.parentJobId)) as "Jobs Ran",
DATEDIFF(WEEK, UTCBigIntToNomTime(domain_JobArchive.endTime), GETDATE()) as "Week#"
FROM
domain_JobArchive , domain_Policy, lookup_PolicyType, domain_MasterServer
WHERE
domain_JobArchive.clientName LIKE 'client1'
AND DATEDIFF(month,UTCBigIntToNomTime(domain_JobArchive.endTime), GETDATE()) <= 1
AND domain_Policy.type= lookup_PolicyType.id
AND domain_JobArchive.masterServerId = domain_MasterServer.id
AND domain_Policy.type = domain_JobArchive.policyType
AND domain_JobArchive.scheduleName != 'unknown'
AND domain_JobArchive.scheduleName != ' '
AND domain_Policy.policyDomainName = domain_JobArchive.policyDomainName
AND domain_Policy.versionNo = domain_JobArchive.policyVersionNo
AND domain_JobArchive.statusCode IN (0,1)
AND domain_JobArchive.type IN (0)
AND domain_JobArchive.presissize !=32768
GROUP BY
"domain_JobArchive"."clientName","lookup_PolicyType"."name","scheduleName","friendlyName",(DATEDIFF(WEEK, UTCBigIntToNomTime(domain_JobArchive.endTime), GETDATE()))
ORDER BY
"domain_JobArchive"."clientName",(DATEDIFF(WEEK, UTCBigIntToNomTime(domain_JobArchive.endTime), GETDATE())),"lookup_PolicyType"."name","scheduleName"
------ output ---- (sanitized to protect the innocent)
Master Server, Client Name, Policy Type, Schedule, GB Written, Jobs Ran, Week#
Master1 client1 Standard full, 30,414 1 0
Master1 client1 Standard incr 4,685 4 0
Master1 client1 Standard full 43,361 1 1
Master1 client1 Standard incr 7,709 6 1
Master1 client1 Standard full 45,751 1 2
Master1 client1 Standard incr 8,555 5 2
Master1 client1 Standard full 44,000 1 3
Master1 client1 Standard incr 7,641 5 3
Master1 client1 Standard incr 7,791 5 4
Sizes expected to be ~ 15 TB for fulls and ~ 2.5 TB for the incs