select a.工号,a.姓名,b.*
from tb_client_db a, (
select
业务指标='全台均值',
成功量=avg(成功量),
实际工时=avg(实际工时),
工效=avg(工效),
拨打时长=avg(拨打时长),
工时占有率=avg(工时占有率),
[成功率(%)]=avg([成功率(%)])
from tb_client_db
union all
select
业务指标='当前最高指标',
成功量=max(成功量),
实际工时=max(实际工时),
工效=max(工效),
拨打时长=max(拨打时长),
工时占有率=max(工时占有率),
[成功率(%)]=max([成功率(%)])
from tb_client_db
)b
union all
select 工号,姓名,
业务指标='个人当前指标',
成功量=(成功量),
实际工时=(实际工时),
工效=(工效),
拨打时长=(拨打时长),
工时占有率=(工时占有率),
回单量=(回单量),
[成功率(%)]=([成功率(%)])
from tb_client_db
union all
select 工号,姓名,
业务指标='个人位列名次',
成功量=(select count(*) from tb_client_db where 成功量>=a.成功量),
实际工时=(select count(*) from tb_client_db where 实际工时>=a.实际工时),
工效=(select count(*) from tb_client_db where 工效>=a.工效),
拨打时长=(select count(*) from tb_client_db where 拨打时长>=a.拨打时长),
工时占有率=(select count(*) from tb_client_db where 工时占有率>=a.工时占有率),
回单量=(select count(*) from tb_client_db where 回单量>=a.回单量),
[成功率(%)]=(select count(*) from tb_client_db where [成功率(%)]>=a.[成功率(%)])
from tb_client_db a
order by 1,2,3