日期:2014-05-16 浏览次数:20969 次
select a.*
from (
select X,count(*) as cnt from (
select num1 as X from test1
union all
select num2 from test1
union all
select num3 from test1
union all
select num4 from test1
) group by X
) a , (
select top 4 cnt from (
select count(*) as cnt from (
select num1 as X from test1
union all
select num2 from test1
union all
select num3 from test1
union all
select num4 from test1
) group by X
) group by cnt
order by 1 desc
) b
where a.cnt=b.cnt