select mobile,count(1) from tb group by mobile having count(1)<6我是来看楼主头像的。
select mobile,count(*) from tableA group by mobile having count(*)>6
select mobile,次数=count(*) from tableA group by mobile having count(*)<6
FYI. ;with MobileAgregation as ( select Mobile , COUNT(1) times from dbo.TableA group by Mobile ) select Agr.times, TA.* from MobileAgregation agr join dbo.TableA TA on agr.Mobile = TA.Mobile where agr.times < 6;
select * from tb ,(select mobile,次数=count(*) from tableA group by mobile having count(*)<6) a where .....
select mobile,count(1) from tb group by mobile having count(1)<6
select * from tb where mobile in (select mobile from tb group by mobile having count(1)<6)
having count(*)>6
select mobile,次数=count(*) from tableA group by mobile
having count(*)<6
;with MobileAgregation
as
(
select
Mobile
, COUNT(1) times
from dbo.TableA
group by Mobile
)
select Agr.times, TA.*
from MobileAgregation agr
join dbo.TableA TA
on agr.Mobile = TA.Mobile
where agr.times < 6;
having count(*)<6) a where .....
having count(1)<6
*
from
tb
where
mobile
in
(select mobile from tb group by mobile having count(1)<6)