zyh196712 发表于 2010-8-24 22:50
select '收益' as 项目,行业,收益,收益笔数,排名,收益笔数*收益 as 汇总 from
(select 行业,收益,coun ... - select '收益' as 项目,行业,收益,收益笔数,排名,收益笔数*收益 as 汇总 from (select 行业,收益,count(收益) as 收益笔数,(select 1+count(*) from (select distinct 行业,收益 from [Sheet1$]) c where c.行业=d.行业 and c.收益>d.收益) as 排名 from [sheet1$] d group by d.行业,d.收益) where 排名<=5
- Union all
- select '行业内收益前5名平均值',x.行业,'','','',avg(x.收益) as 行业内收益前5名平均值 from [sheet1$] x,(select 行业,收益,(select 1+count(*) from (select distinct 行业,收益 from [Sheet1$]) a where a.行业=b.行业 and a.收益>b.收益) as 排名1 from (select distinct 行业,收益 from [sheet1$]) b) y where x.行业=y.行业 and x.收益=y.收益 and y.排名1<=5 group by x.行业
复制代码
楼主,你是怎么写出来的????学习中…… |