Select c.人员名称,a.建立日期,count(b.回复编号) as 回复数,
       b.最后回复日期,b.最后回复人员名称
from table1 as a inner join table3 as c on a.人员编号=c.人员编号
    Left Join (select top 1 x.序号,y.人员名称 as 最后回复人员名称,
               x.回复日期 as 最后回复日期
               from table2 as x
               inner join table3 as y on x.回复人员编号=y.人员编号
               order by x.回复日期 Desc) as b
    on b.序号=a.序号
group by c.人员名称,a.建立日期,b.最后回复日期,b.最后回复人员名称

解决方案 »

  1.   

    本来写好了的,结果没发出来,痛苦ingselect 
        d.fd_uname,a.fd_date,b.count_num,max(c.fd_rdate),d.fd_uname
    from 
        table1 a,
        (select count(*) as count_num,fd_pid from table2 group by fd_pid) b,
        table2 c,
        table3 d
    where 
        d.fd_uid=a.fd_uid(+)
    and d.fd_uid=b.fd_uid(+)
    and d.fd_uid=c.fd_uid(+)
    and b.fd_rid=c.fd_rid没有数据检验,不行的话自己再调试一下