日期:2014-05-17 浏览次数:20522 次
declare @T1 table (e int,f int,g int) insert into @T1 select 1,2,3 union all select 1,2,3 union all select 2,3,4 union all select 2,3,5 union all select 2,3,5 union all select 2,3,6 union all select 2,3,6 union all select 2,3,6 union all select 2,3,7 union all select 2,3,7 union all select 2,3,7 union all select 2,3,7 union all select 2,3,8 union all select 2,3,8 union all select 2,3,8 union all select 2,3,8 union all select 2,3,8 union all select 2,3,8 select e,f,g from (select e,f,g,count(*) fc from @t1 group by e,f,g) a where ((select max(fc) from (select count(*) fc from @t1 group by e,f,g) b)+ (select min(fc) from (select count(*) fc from @t1 group by e,f,g) b))/2.0-fc=1.5 --测试数据中最大值是2、3、8有6条。 --测试数据中最小值是2、3、4有1条。 --平均就是3.5 ,减去fc=1.5的话,fc=2 --得到结果为: /* e f g ----------- ----------- ----------- 1 2 3 2 3 5 */
------解决方案--------------------