select count(cou_code) as Changes
from sdrp15_cosd
where sd_code in
(select sd_code from sdrp15_submission_log
where QA_date is null)
它给了我结果
更改| 629
select count(cou_code) as Complete
from sdrp15_cosd
where sd_code in
(select sd_code from sdrp15_submission_log
where QA_date is not null)
它给了我结果
完成| 210
我希望有2列一个名为的更改,一个名为complete,其中两个查询(上图)合并为一个查询
答案 0 :(得分:1)
进行两次条件计数(使用CASE
),一次用于is null
,一次用于is not null
。
select count(case when sd_code in (select sd_code from sdrp15_submission_log
where QA_date is null) then 1 end) as Changes,
count(case when sd_code in (select sd_code from sdrp15_submission_log
where QA_date is not null) then 1 end) as Complete
from sdrp15_cosd
答案 1 :(得分:0)
尝试UNION
select count(cou_code) as Changes from sdrp15_cosd where sd_code in
(select sd_code from sdrp15_submission_log where QA_date is null)
UNION
select count(cou_code) as Complete from sdrp15_cosd where sd_code in
(select sd_code from sdrp15_submission_log where QA_date is not null)