自己试一下吧!(我没测试)
select c.n_year 年,c.n_month 月,c.c_custtype 客户类型, count(distinct C.C_CUSTNO) 开户数
from
(select a.C_CUSTNO,a.c_custtype,b.year(d_date) n_year,b.month(d_date) n_month from cc_trequest a
inner join
(select C_CUSTNO,min(D_DATE) d_date from cc_trequest group by C_CUSTNO) b
on a.C_CUSTNO=b.C_CUSTNO and a.d_date=b.d_date) c
group by c.n_year,c.n_month,c_custtype