I'm looking to do an update for a batch when all the jobs for that batch are completed. To do this I want to compare the total number of jobs vs the total completed. I'm doing that with the query below, however it's a pretty slow query. Any suggestions to improve this? Or alternate ways to approach the main update?
SELECT DISTINCT j.BatchId,
j.JobStatusId,
COUNT(j.BatchId) OVER(PARTITION BY j.BatchID, j.JobStatusID),
COUNT(j.BatchId) OVER(PARTITION BY j.BatchID)
FROM [Job] j
ORDER BY j.BatchID
Aucun commentaire:
Enregistrer un commentaire