Делаю запрос:
select kontr_l_pr, post_pr,
count(case when vpl_main_pr = 'да' and vpl_main_pr is not null and (date_pr between @DateBeginning and @DateEnding) then 1 end) cnt_yes,
count(case when vpl_main_pr = 'на исполнении' and vpl_main_pr is not null and (date_pr between @DateBeginning and @DateEnding)then 1 end) cnt_ni,
count(case when vpl_main_pr = 'нет' and vpl_main_pr is not null and (date_pr between @DateBeginning and @DateEnding)then 1 end) cnt_no,
count(case when vpl_main_pr = 'просрочен' and vpl_main_pr is not null and (date_pr between @DateBeginning and @DateEnding) then 1 end) cnt_pr,
count(case when vpl_main_pr = 'постоянный контроль'and vpl_main_pr is not null and (date_pr between @DateBeginning and @DateEnding) then 1 end) cnt_pk,
count(case when (vpl_main_pr = 'да' or vpl_main_pr = 'на исполнении' or vpl_main_pr = 'нет' or vpl_main_pr = 'просрочен' or vpl_main_pr = 'постоянный контроль') and vpl_main_pr is not null and (date_pr between '01.01.2011' and @DateEnding) then 1 end) cnt_all
from
(
select kontr_l_pr, post_pr, vpl_main_pr, date_pr from pr
union
select kontr_l, post_por, vpl_main_por, date_por from Por
union
select kontr_l_prt, post_prt, vpl_main_prt, date_prt from prt
union
select kontr_l_rez, post_rez, vpl_main_rez, date_rez from rez
union
select kontr_l_in, post_in, vpl_main_in, date_in from in_dok
) t where vpl_main_pr is not null
group by kontr_l_pr, post_pr
order by kontr_l_pr
В результате получаю:
cnt_yes cnt_ni cnt_no cnt_pr cnt_pk cnt_all
Иванов Иван Иванович директор 0 0 0 1 0 1
Сидоров Сидор Сидорович начальник 1 1 2 3 1 4 11
Петров Петр Петрович начальник 2 0 0 0 0 0 1
Подскажите, пожалуйста, как дописать запрос, чтобы строка, где значения столбцов (cnt_yes cnt_ni cnt_no cnt_pr cnt_pk) равны нулю не выводилась в результат запроса