我是 sql 新手,正在尝试执行以下操作:
我的查询当前基于 where 子句拉回两个字段:
select distinct
count(distinct t1.p_id) "c1",
count(distinct t2.sa_id) "c2"
from capd_section t5,
capd_department t6,
capd_person t1,
capd_studentapplication t2,
capd_module t4,
capd_moduleapplication t3
where (t3.ma_studentapplication(+)=t2.sa_id) and
(t3.ma_module=t4.m_id(+)) and
(t4.m_modulesection=t5.s_id(+)) and
(t4.m_moduledept=t6.d_id(+)) and
(t4.m_reference not like '%%FTA%%') and
**(t2.sa_reference like '212%%')** and
(t4.m_reference not like '%%HE%%') and
(t4.m_reference not like '%%PT%%') and
(t4.m_name not like 'NCTJ%%') and
(t4.m_reference not like 'ME%%') and
(t2.sa_student=t1.p_id)
having (count(distinct t3.ma_id)>0)
我想要相同的查询,但也需要使用 where 子句(t2.sa_reference like '213%%')。(当年和上一年)
所以总共四个字段(c1,c2,c3,c4)。如果这有任何意义的话。甚至可能吗?
非常感谢您的帮助:)