0
SELECT
    domain_Job.statusCode as "Status Code",
    lookup_JobStatusCode.name as "Status Code Description"
    FROM
    domain_Job, domain_Client, lookup_JobStatusCode, domain_MasterServer, lookup_JobType, lookup_JobState
    WHERE
    domain_Job.type = lookup_JobType.id AND
    domain_Job.statusCode > 1 AND
    domain_Job.statusCode = lookup_JobStatusCode.id AND
    domain_Job.id = domain_Job.ParentJobID AND
    domain_Job.state = lookup_JobState.id AND
    domain_Job.clientName = domain_Client.name AND
    DATEDIFF(hour,UTCBigIntToNomTime(domain_Job.endTime), GETDATE()) <=24 AND
    domain_Job.policyName != ''
    GROUP BY domain_Job.statusCode, lookup_JobStatusCode.name, domain_MasterServer.networkName, lookup_JobType.name, lookup_JobState.name

output :

Status Code |   Status Code Description
47          | host is unreachable 
7648        | - 
96          | unable to allocate new media for backup, storage unit has none available 
191         | no images were successfully processed 
806         | this mpx group is unjoinable 
47          | host is unreachable 
7648        | - 
156         | snapshot error encountered 
20          | invalid command parameter 
4234        | VMware server login failure 
4
  • can someone help paste my output in table and help with query with desired output. Commented Jul 11, 2019 at 7:09
  • Use your query as a subquery. Group and count in outer query.
    – Akina
    Commented Jul 11, 2019 at 7:17
  • can you help me with query Commented Jul 12, 2019 at 5:03
  • Sybase SQL Anywhere knows about window version of COUNT() function. Add COUNT(*) OVER (PARTITION BY domain_Job.statusCode) AS "Count" to output fields list.
    – Akina
    Commented Jul 12, 2019 at 5:10

1 Answer 1

0
SELECT
    domain_Job.statusCode as "Status Code",
    lookup_JobStatusCode.name as "Status Code Description",
    COUNT(*) OVER (PARTITION BY domain_Job.statusCode) as "Count"
FROM
    domain_Job, domain_Client, lookup_JobStatusCode, domain_MasterServer, lookup_JobType, lookup_JobState
WHERE
    domain_Job.type = lookup_JobType.id AND
    domain_Job.statusCode > 1 AND
    domain_Job.statusCode = lookup_JobStatusCode.id AND
    domain_Job.id = domain_Job.ParentJobID AND
    domain_Job.state = lookup_JobState.id AND
    domain_Job.clientName = domain_Client.name AND
    DATEDIFF(hour, UTCBigIntToNomTime(domain_Job.endTime), GETDATE()) <= 24 AND
    domain_Job.policyName != ''
GROUP BY domain_Job.statusCode, lookup_JobStatusCode.name, domain_MasterServer.networkName, lookup_JobType.name, lookup_JobState.name

Status Code | Status Code Description                  | Count
-------------------------------------------------------------
47          | host is unreachable                     | 2
7648        | -                                      | 2
96          | unable to allocate new media for backup | 1
191         | no images were successfully processed   | 1
806         | this mpx group is unjoinable            | 1
20          | invalid command parameter               | 1
4234        | VMware server login failure             | 1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.