回复 14楼 张汉卿
没什么大问题,只是那个"b."写错位置了,应该写在括号内!
select c.n_year 年,c.n_month 月,c.c_custtype 客户类型, count(distinct c.C_CUSTNO) 开户数
from
(select a.C_CUSTNO,a.c_custtype,year(b.d_date) n_year,month(b.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
[
本帖最后由 cnfarer 于 2010-4-22 12:21 编辑 ]