谁能帮我计算我应该如何计算jq.batchid != 0 and tl.taskqueueid IS NOT NULL
这是初始数据:
+---------------+-----------+---------+---------------+
| taskqueueid | batchid | jobid | taskqueueid |
+---------------+-----------+---------+---------------+
| 19 | 0 | 140 | (NULL) |
+---------------+-----------+---------+---------------+
| 21 | 103 | 140 | 21 |
+---------------+-----------+---------+---------------+
| 22 | 104 | 140 | 22 |
+---------------+-----------+---------+---------------+
| 23 | 105 | 140 | (NULL) |
+---------------+-----------+---------+---------------+
| 20 | 0 | 140 | (NULL) |
+---------------+-----------+---------+---------------+
这是我的查询:
SELECT COUNT(jq.batchid),COUNT(tl.taskqueueid)
FROM jobqueue jq
LEFT JOIN taskslogs tl
ON jq.taskqueueid=tl.taskqueueid
AND jq.documentgroupid=0
AND jq.batchid!=0
AND tl.statusDefinitionID=1
WHERE jq.jobid=140;
上面的查询结果是:
+--------------------+-----------------------+
| COUNT(jq.batchid) | COUNT(tl.taskqueueid) |
+--------------------+-----------------------+
| 5 | 2 |
+--------------------+-----------------------+
我想要一个结果:
+--------------------+-----------------------+
| COUNT(jq.batchid) | COUNT(tl.taskqueueid) |
+--------------------+-----------------------+
| 3 | 2 |
+--------------------+-----------------------+
任何人都可以帮助我如何做到这一点。