I am totally stuck on the best way to write SQL code to handle a task I have to produce a report. We use Sybase ASA. It is embedded with an application. The query needs to produce the following output:
Media Server | Total NUmber of Backups | Volume Size (KB) | Average Throughput | Number of Successful | Jobs Success %
Each media server would be unique.
I am having an issue with getting the Number of successful jobs and then determining the % of Success.
Here is the code that I have:
SELECT
dmj.name AS "Media Server",
CAST(SUM(dj.bytesWritten/1024/1024) as decimal(20,2)) as "Volume(MB)",
COUNT(distinct dj.id) AS "Total Number of Jobs",
CAST(AVG(dj.throughput) as decimal(10,2)) AS "Throughput (KB/sec)",
CASE
WHEN dj.statusCode = '0'
THEN COUNT (dj.statusCode)
END AS "Number of Successful Jobs"
FROM domain_JobArchive dj
INNER JOIN domain_MediaServer dmj
ON dj.mediaServerName = dmj.name
WHERE DATEDIFF(day, UtcBigIntToNomTime(dj.endTime), GETDATE()) <= 7
AND dj.Type != '17'
AND dj.statusCode = 0
GROUP BY dmj.name, dj.statusCode
I am also still unsure how to show the % of success.
We use Sybase ASA as it is embedded in an application.
Thanks.