select max(_n) from
(select hm as _hm,jz as _jz,count(hm) as _n
from ab.dbo.xd4
where jz in (select jz from ab.dbo.xdjz)
group by hm,jz order by _hm,_n desc ) as tablename
(select hm as _hm,jz as _jz,count(hm) as _n
from ab.dbo.xd4
where jz in (select jz from ab.dbo.xdjz)
group by hm,jz order by _hm,_n desc ) as tablename
select _hm,_jz,max(_n) from
(select hm as _hm,jz as _jz,count(hm) as _n
from ab.dbo.xd4
where jz in (select jz from ab.dbo.xdjz)
group by hm,jz order by _hm,_n desc ) as tablename
group by _hm,_jz
(select hm as _hm,jz as _jz,count(hm) as _n
from ab.dbo.xd4
where jz in (select jz from ab.dbo.xdjz)
group by hm,jz order by _hm,_n desc ) as tablename
group by _hm
select hm as _hm,jz as _jz,count(hm) as _n
from xd4
where jz in (select jz from xdjz)
group by hm,jz order by _hm,_n desc
只想选出 同一个hm 中 _n 最大的纪录
或者在
hm jz n 三个字段的表中
号码相同的纪录有很多,对应不同的 jz ,n
现在只想挑出 同一个号码 n 最大的纪录
的所有号码,对应的jz,n的集合
from xd4 where jz in (select jz from xdjz)
group by hm,jz
order by count(hm) desc
(select hm ,count(*) as cnt from ab.dbo.xd4
where hm in
(select top 1 hm from ab.dbo.xd4 group by hm order by count(*) desc)
group by hm
) T1
inner join xdjz T2 ON T1.hm=T2.hm