日期:2014-05-18 浏览次数:20560 次
SELECT A.F_GSID,a.f_date ,F_0026=(SELECT COUNT(*) FROM C1T13 m WHERE m.F_GSID= a.F_GSID AND m.F_SJRQ= CAST(A.F_YEAR AS varchar)+'1231') ,F_0027=(SELECT AVG(LEFT(a.F_YEAR,4)-m.F_1002) FROM m..C1T13 m WHERE m.F_GSID= a.F_GSID AND m.F_SJRQ= CAST(a.F_YEAR AS varchar)+'1231' AND m.F_1002>1900 AND m.F_1002<9999) from C1T05 a
SELECT A.F_GSID,a.f_date ,a.num , AVG(LEFT(b.F_YEAR,4)-m.F_1002) from C1T05 b, (select F_GSID,count(1) as num from C1T13 group by F_GSID)a, C1T13 m where m.F_GSID= a.F_GSID AND m.F_SJRQ= CAST(A.F_YEAR AS varchar)+'1231' AND m.F_1002>1900 AND m.F_1002<9999 and a.f_gsid=b.f_gsid and a.f_date=b.f_date